Changeset 1113c9e in mainline for uspace/dist/src/sysel/lib/list.sy
- Timestamp:
- 2010-06-09T19:03:24Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 8eec3c8
- Parents:
- 8f80c77 (diff), c5cb943d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/lib/list.sy
r8f80c77 r1113c9e 28 28 29 29 -- Doubly-linked list. 30 class List/t is30 class List/t : IEnumerable/t is 31 31 var head : ListNode/t; 32 32 … … 59 59 prop First : ListNode/t is 60 60 get is 61 61 return get_first(); 62 62 end 63 end 64 65 -- Return first node in the list or @c nil if there is none. 66 fun GetEnumerator() : IEnumerator/t is 67 return new ListEnumerator/t(get_first()); 63 68 end 64 69 … … 131 136 end 132 137 end 138 end 133 139 140 class ListEnumerator/t : IEnumerator/t is 141 var first : ListNode/t; 142 var current : ListNode/t; 143 var started : bool; 144 145 new(first_node : ListNode/t) is 146 first = first_node; 147 current = nil; 148 started = false; 149 end 150 151 fun MoveNext() : bool is 152 if started then 153 current = current.Next; 154 else 155 current = first; 156 started = true; 157 end 158 159 return current != nil; 160 end 161 162 prop Data : t is 163 get is 164 return current.Data; 165 end 166 end 134 167 end
Note:
See TracChangeset
for help on using the changeset viewer.