blob: c7970178a4dd471bffd558b735605531502f61ef (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
struct Iterator {
~Vector v,
int pos
}
/; method Iterator
/; init(~Vector v)
self.v = v
self.pos = 0
;/
/; get [~void]
return self.v`.get(self.pos)
;/
/; next
/; if (self.pos + 1 < self.v`.count)
self.pos++
;/
;/
/; at_end [bool]
return (self.pos + 1) !< (self.v`.count)
;/
/; prev
/; if (self.pos > 0)
self.pos--
;/
;/
/; get_pos [int]
return self.pos
;/
/; set_pos (int p)
self.pos = p
;/
;/
|