Changeset 1113c9e in mainline for uspace/dist/src/sysel/lib/list.sy


Ignore:
Timestamp:
2010-06-09T19:03:24Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
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.
Message:

Merge from lp:~jsvoboda/helenos/sysel.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/dist/src/sysel/lib/list.sy

    r8f80c77 r1113c9e  
    2828
    2929-- Doubly-linked list.
    30 class List/t is
     30class List/t : IEnumerable/t is
    3131        var head : ListNode/t;
    3232
     
    5959        prop First : ListNode/t is
    6060                get is
    61                     return get_first();
     61                        return get_first();
    6262                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());
    6368        end
    6469
     
    131136                end
    132137        end
     138end
    133139
     140class 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
    134167end
Note: See TracChangeset for help on using the changeset viewer.