Changeset 1de50a9 for libcfa/src/bits/queue.hfa
- Timestamp:
- Dec 3, 2020, 8:58:29 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 032fd93
- Parents:
- cf2257f (diff), 7b2a786 (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
-
libcfa/src/bits/queue.hfa
rcf2257f r1de50a9 27 27 } 28 28 29 T & succ( Queue(T) & q, T &n ) with( q ) { // pre: *n in *q29 T * succ( Queue(T) & q, T * n ) with( q ) { // pre: *n in *q 30 30 #ifdef __CFA_DEBUG__ 31 if ( ! listed( &n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, &n );31 if ( ! listed( n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, n ); 32 32 #endif // __CFA_DEBUG__ 33 return (Next( &n ) == &n) ? *0p : *Next( &n );33 return (Next( n ) == n) ? 0p : Next( n ); 34 34 } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q 35 35 … … 62 62 63 63 T & dropHead( Queue(T) & q ) with( q ) { 64 T * t = &head( q );64 T & t = head( q ); 65 65 if ( root ) { 66 66 root = Next( root ); 67 if ( &head( q ) == t ) {67 if ( &head( q ) == &t ) { 68 68 root = last = 0p; // only one element 69 69 } 70 Next( t ) = 0p;70 Next( &t ) = 0p; 71 71 } 72 return *t;72 return t; 73 73 } 74 74 … … 81 81 if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n ); 82 82 #endif // __CFA_DEBUG__ 83 T * prev = 0 ;83 T * prev = 0p; 84 84 T * curr = (T *)root; 85 85 for ( ;; ) { 86 if ( &n == curr) { // found => remove87 if ( (T *)root == &n) {86 if ( &n == curr ) { // found => remove 87 if ( (T *)root == &n ) { 88 88 dropHead( q ); 89 } else if ( last == &n) {89 } else if ( last == &n ) { 90 90 last = prev; 91 91 Next( last ) = last; … … 132 132 to.last = &n; // end of "to" list 133 133 from.root = Next( &n ); // start of "from" list 134 if ( &n == &head( from ) ) { 134 if ( &n == &head( from ) ) { // last node in list ? 135 135 from.root = from.last = 0p; // mark "from" list empty 136 136 } else { 137 Next( &n ) = &n; 137 Next( &n ) = &n; // fix end of "to" list 138 138 } 139 139 transfer( q, to ); … … 179 179 180 180 // Local Variables: // 181 // compile-command: " make install" //181 // compile-command: "cfa queue.cfa" // 182 182 // End: //
Note: See TracChangeset
for help on using the changeset viewer.