Skip to content

Commit c15a931

Browse files
committed
circular_list: Add [] implementation
Signed-off-by: Delja <deljarry.florian@gmail.com>
1 parent 6e843ca commit c15a931

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

examples/circular_list.nit

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ class CircularList[E]
2929

3030
redef fun first do return self.node.item
3131

32+
redef fun [](index) do
33+
var i = 0
34+
for item in self do
35+
if i == index then return item
36+
i += 1
37+
end
38+
return null
39+
end
40+
3241
redef fun push(e)
3342
do
3443
var new_node = new CLNode[E](e)

0 commit comments

Comments
 (0)