Changes in libcfa/src/bits/queue.hfa [a3a76ea:9536761]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/queue.hfa
ra3a76ea r9536761 2 2 3 3 #include "bits/collection.hfa" 4 5 // A Queue(T) is a Collection(T) defining the ordering that nodes are returned by drop() in the same order from those 6 // added by add(). T must be a public descendant of uColable. 7 8 // The implementation is a typical singly-linked list, except the next field of the last element points to itself 9 // instead of being null. 4 10 5 11 forall( dtype T | { T *& Next ( T * ); } ) { … … 108 114 } // post: ! listed( n ) 109 115 110 T & dropTail( Queue(T) & q ) with( q ) { 116 T & dropTail( Queue(T) & q ) with( q ) { // O(n) 111 117 T & n = tail( q ); 112 118 return &n ? remove( q, n ), n : *0p; … … 155 161 } // post: curr == 0p 156 162 157 // create an iterator active in Queue q163 // create an iterator active in queue q 158 164 void ?{}( QueueIter(T) & qi, Queue(T) & q ) with( qi ) { 159 165 curr = &head( q ); … … 164 170 } // post: curr = {e in q} 165 171 166 // make existing iterator active in Queue q172 // make existing iterator active in queue q 167 173 void over( QueueIter(T) & qi, Queue(T) & q ) with( qi ) { 168 174 curr = &head( q ); 169 175 } // post: curr = {e in q} 170 176 171 bool ? >>?( QueueIter(T) & qi, T && tp ) with( qi ) {177 bool ?|?( QueueIter(T) & qi, T && tp ) with( qi ) { 172 178 if ( curr ) { 173 179 &tp = Curr( qi ); … … 177 183 return &tp != 0p; 178 184 } 179 // post: elts == null & !operator >>(tp) | elts != null & *tp' in elts & elts' == elts - *tp & operator>>(tp)185 // post: elts == null & !operator|(tp) | elts != null & *tp' in elts & elts' == elts - *tp & operator|(tp) 180 186 } // distribution 181 187 } // distribution
Note: See TracChangeset
for help on using the changeset viewer.