Changeset 38aaacc2 in mainline for uspace/dist/src/sysel/lib/list.sy
- Timestamp:
- 2010-04-23T21:41:10Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f4f866c
- Parents:
- 074444f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/lib/list.sy
r074444f r38aaacc2 27 27 -- 28 28 29 -- Doubly-linked non-genericlist.30 class List is31 var head : ListNode ;29 -- Doubly-linked list. 30 class List/t is 31 var head : ListNode/t; 32 32 33 33 -- Initialize list. 34 34 fun Init() is 35 head = new ListNode ();35 head = new ListNode/t(); 36 36 head.prev = head; 37 37 head.next = head; … … 39 39 40 40 -- Append new entry at the end of the list. 41 fun Append(data : Object) is42 var n : ListNode ;43 var ntl : ListNode ;41 fun Append(data : t) is 42 var n : ListNode/t; 43 var ntl : ListNode/t; 44 44 45 45 ntl = head.prev; 46 46 47 n = new ListNode ();47 n = new ListNode/t(); 48 48 n.value = data; 49 49 … … 57 57 58 58 -- Return first node in the list or @c nil if there is none. 59 prop First : ListNode is59 prop First : ListNode/t is 60 60 get is 61 61 return get_first(); … … 64 64 65 65 -- Return first node in the list or @c nil if there is none. 66 fun get_first() : ListNode is66 fun get_first() : ListNode/t is 67 67 if head.next == head then 68 68 return nil; … … 73 73 end 74 74 75 class ListNode is76 var value : Object;75 class ListNode/t is 76 var value : t; 77 77 78 var prev : ListNode ;79 var next : ListNode ;80 var head : ListNode ;78 var prev : ListNode/t; 79 var next : ListNode/t; 80 var head : ListNode/t; 81 81 82 82 -- Value stored in this node. 83 prop Value : Object is83 prop Value : t is 84 84 get is 85 85 return value; … … 88 88 89 89 -- Previous node in list. 90 prop Prev : ListNode is90 prop Prev : ListNode/t is 91 91 get is 92 92 return get_prev(); … … 95 95 96 96 -- Next node in list. 97 prop Next : ListNode is97 prop Next : ListNode/t is 98 98 get is 99 99 return get_next(); … … 102 102 103 103 -- Get next node. 104 fun get_next() : ListNode is104 fun get_next() : ListNode/t is 105 105 if next != head then 106 106 return next; … … 111 111 112 112 -- Get previous node. 113 fun get_prev() : ListNode is113 fun get_prev() : ListNode/t is 114 114 if prev != head then 115 115 return next;
Note:
See TracChangeset
for help on using the changeset viewer.