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