In the last lesson will you get it did it are specific to all kinds of collection objects. 2
Non-Earth look at the list or Twitter which is specific to only less unindexed answer. 3
It did it an interface on hands but with some additional functionality as well we'll see in this lesson 4
if you recall we briefly mentioned about these new methods that list interface uploads. 5
But we did not get into any details of this methods but these methods return an instance of Lister did 6
it. 7
Second one read and then listed the data starting from a particular index and the current list on what 8
is the list the written interface it extends it to later on provides additional functionality. 9
Little did it or we could only remove elements but using it later we can additionally add on Also replace 10
elements. 11
Moreover we can also iterate both forwards as well as backwards. 12
That is it also supports bidirectional access. 13
So we now have next our next. 14
Just like in the case of regulator but in addition we also have Hosp. previous on previous previous 15
would simply return the previous element. 16
There are also the methods. 17
Next and next and previous and next which give the index numbers of next on previous elements. 18
Now here due to the bi directional axis remove motard would remove the element that was returned by 19
the immediately preceding cone which has to be either next or previous. 20
Otherwise an illegal state exception will be thrown in the case of a traitor. 21
It was only the next invocation as there was no previous method any iterator. 22
So the preceding call was an indication of next method then the element that was returned by that particular 23
next invocation would be removed. 24
But if the preceding call was an location of previous Medad then the element that was returned by that 25
particular location or previous method would be more similar semantics would also apply for such a method 26
. 27
That is it updates the last element written by next our previous segment that would throw an illegal 28
state exception if the immediate preceding call is not next or previous or better. 29
So the immediately preceding call can be a segmented augmented simply adds an element an update updates 30
the cursor position in the next slide. 31
They will look at how the cursor works. 32
So basically Mr. Twitter is a more Richard Ritter as it extends the reader interface and in terms of 33
applications it may be useful for cross entries. 34
Another application could be with installation software many times with such installation software. 35
We go through multiple steps by clicking on the next button but then the software also provides back 36
buttons where you can go back from the current screen in order to make any edits. 37
So if a list or Twitter can be used with installation software in order to move forward it's as well 38
as backwards. 39
And here is something about the cursor position in this illustration. 40
And elements from index 0 2 index and minus one. 41
Now the red arrow indicates a up position so the cursor is in between two elements. 42
It means that there is no concept of current element. 43
Mr. Director that's the reason we have methods like next next next previous and next and previous. 44
So there is no current index. 45
So when we start that duration and we end up next index it would return zero. 46
Similarly when we were previous indexed at the start of integration it would read an A minus one NAAFI 47
next index when the cursor is at the end of the list. 48
Then the size of the list would be returned. 49
One thing to note here is let's say the cursor is in between. 50
And this is zero on one NAAFI And what next method then element that in Expedition 1 would be written 51
on the set would be in-between indices VH1 onto Nolfi in your previous method. 52
Then once again the element that index position 1 would be written. 53
So it's not going to return the element that index position zero. 54
So to give the element index zero we need to invoke previous one more time. 55
So that's a kind of behavior we get during the week Kosar works. 56
Now let's head over to my eclipse to look at a shot them off list or did it or looking for wisdom or 57
a new method card list. 58
It did it for them or has been added to the list smokeless. 59
So in just a month you're not going to write any new Coke in the interest of time. 60
The matter has already been written so we're just going to look at the statements and we are going to 61
execute this matter. 62
So here we are creating another list and we are adding three elements. 63
These are strengths. 64
A B and C since it's an idealist all strings. 65
So here we have a string here. 66
So it's a list of strings and we are going to display the elements first. 67
So here. 68
So the element name and the Orderless name is list. 69
So we're invoking the list. 70
It didn't matter here under-treated and said list iterator off strings. 71
OK and here we are using a furler in the previous DM or we used a y know what it did it in did it. 72
But here in this case we are using the fuddle and we invoking the Hasek's method in order to do that 73
. 74
OK. 75
So there is no increment operation so this expression is empty here and we are simply printing the next 76
index as well as the next element. 77
So let me run this as you can see it is printing the next numbers 0 1 2 and the corresponding elements 78
. 79
Now let's go ahead and run the rest of the code. 80
Next we are actually demonstrative. 81
I remove. 82
I insert operations. 83
So let's look at each of them separately. 84
So let me just. 85
OK so let me run it. 86
So once again we are drifting through the list iterator. 87
OK let's just the same for a for loop here. 88
Let's look at the output. 89
OK here we are. 90
So here initially initially we are printing the next index. 91
Here it is. 92
So it is zero and we are also printing the element which is a. 93
Then once we do that we are invoking the next and next one more time. 94
OK. 95
And that next index would be equal to 1. 96
Right. 97
Because the first time and it was in vogue because you don't know to be one on one it is what we want 98
to do. 99
A few operations here. 100
One thing is we are printing the statement adding tested and next one here today. 101
So we are going to add an element here. 102
OK. 103
So we are in the odd method on the iterator on the listed editor and it is adding this element called 104
test. 105
OK. 106
Now this word I don't aliment under-covered Edwins the cursor. 107
So when we invoke the next index here and the next statement it is actually ending the next two. 108
So the element got. 109
I did it in next one. 110
It's just that the cursor got advanced and that's the reason when we invoke next index it is printing 111
too. 112
And here we are in working the next element. 113
You did it or not. 114
Next on that would actually return the element B which is which is now at position two. 115
OK previous Newt was at position 1. 116
So that's the odd operation. 117
It's simply arch on advances the cursor position. 118
Now let's look at the remote moment here. 119
So we want to really muck best which was I did it in Expedition 1 but not the current position cursor 120
position as B. 121
Is it too. 122
Sorry. 123
Is it to iron when we invoke it did it or previous It would return that element B. 124
Ok so here we are invoking the previous. 125
But our goal is to remove the element test. 126
So we need to invoke previous one more time here and when we do that then the element best would be 127
returned. 128
Now the goal is to remove the element test so we invoke the motard Rimmel. 129
And so the previous since the previous call was lost previous which was returning the element test the 130
remote work return that particular element. 131
So we already discussed that the the preceding call would be more has to be either previous or it has 132
to be next. 133
Otherwise we get it we get an exception. 134
So that's the remote amateur knowledge look at set operation for that operation here. 135
Let me uncomment this sort of for the search operation. 136
The preceding call has to be next or previous or set. 137
So in this case the preceding cannulas the Rimmel. 138
So in this case now if I run it it should give an illegal state exception as you can see it gives an 139
legal state exception. 140
So you cannot do that. 141
So let me comment it out and then let me read on this. 142
So now the element test has already been removed. 143
So we are here on we are trending the next index. 144
So the next and next will be one and the next element would be B. 145
So now B is back at Expedition 1. 146
Now we want to execute a set matter here and we want to set the element at index 1 as test. 147
So we want to replace beb it best since here next has already been invoked in this system brought out 148
statement. 149
So we are free to use the set method. 150
And so we are setting test now in the next statement. 151
We want to set the aliment for them. 152
We want to replace best met test the string test but just one. 153
So we are setting one more time. 154
So we are setting or just test one since set can be preceded by a set call. 155
So it is perfectly fine on just would be replaced by Test 1. 156
OK. 157
So finally we are printing all the elements here. 158
Once again we are using a fun loop. 159
Now we now only have three elements in just one on seat. 160
So that's the list iterator interface. 161
And you can see that it supports previous next Raymo. 162
And also segments. 163
So it's a much more richer and richer. 164
So that's about it. 165
The code is available in the resource section. 166
Thank you. 167
Unhappy coding.