Changeset 37f527b in mainline for uspace/dist/sysel/list.sy
- Timestamp:
- 2010-03-26T21:55:23Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4204ad9
- Parents:
- b535aeb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/sysel/list.sy
rb535aeb r37f527b 27 27 -- 28 28 29 -- Doubly-linked list implementation. 29 30 class List is 30 31 var head : ListNode; 31 32 33 -- Initialize list. 32 34 fun Init() is 33 35 head = new ListNode(); … … 36 38 end 37 39 40 -- Append new entry at the end of the list. 38 41 fun Append(data : int) is 39 42 var n : ListNode; … … 53 56 end 54 57 55 fun GetFirst() : ListNode is 56 return head.next; 58 -- Return first node in the list or @c nil if there is none. 59 prop First : ListNode is 60 get is 61 return get_first(); 62 end 63 end 64 65 -- Return first node in the list or @c nil if there is none. 66 fun get_first() : ListNode is 67 if head.next == head then 68 return nil; 69 else 70 return head.next; 71 end 57 72 end 58 73 end … … 65 80 var head : ListNode; 66 81 67 fun GetNext() : ListNode is 82 -- Value stored in this node. 83 prop Value : int is 84 get is 85 return value; 86 end 87 end 88 89 -- Previous node in list. 90 prop Prev : ListNode is 91 get is 92 return get_prev(); 93 end 94 end 95 96 -- Next node in list. 97 prop Next : ListNode is 98 get is 99 return get_next(); 100 end 101 end 102 103 -- Get next node. 104 fun get_next() : ListNode is 68 105 if next != head then 69 106 return next; … … 73 110 end 74 111 75 fun GetPrev() : ListNode is 112 -- Get previous node. 113 fun get_prev() : ListNode is 76 114 if prev != head then 77 115 return next; … … 81 119 end 82 120 83 fun GetValue() : int is84 return value;85 end86 121 end 87 122 … … 100 135 var n : ListNode; 101 136 102 n = list. GetFirst();137 n = list.First; 103 138 while n != nil do 104 139 Builtin.WriteLine(n.value); 105 n = n. GetNext();140 n = n.Next; 106 141 end 107 142 end
Note:
See TracChangeset
for help on using the changeset viewer.