Changeset 3f91792 for libcfa/src/bits/queue.hfa
- Timestamp:
- Dec 8, 2020, 1:01:05 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:
- 8e58264
- Parents:
- 33a129a (diff), c9e0991 (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
r33a129a r3f91792 28 28 29 29 T * succ( Queue(T) & q, T * n ) with( q ) { // pre: *n in *q 30 #ifdef __CFA_DEBUG__30 #ifdef __CFA_DEBUG__ 31 31 if ( ! listed( n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, n ); 32 #endif // __CFA_DEBUG__32 #endif // __CFA_DEBUG__ 33 33 return (Next( n ) == n) ? 0p : Next( n ); 34 34 } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q 35 35 36 36 void addHead( Queue(T) & q, T & n ) with( q ) { 37 #ifdef __CFA_DEBUG__37 #ifdef __CFA_DEBUG__ 38 38 if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n ); 39 #endif // __CFA_DEBUG__39 #endif // __CFA_DEBUG__ 40 40 if ( last ) { 41 41 Next( &n ) = &head( q ); … … 43 43 } else { 44 44 root = last = &n; 45 Next( &n ) = &n; 45 Next( &n ) = &n; // last node points to itself 46 46 } 47 47 } 48 48 49 49 void addTail( Queue(T) & q, T & n ) with( q ) { 50 #ifdef __CFA_DEBUG__50 #ifdef __CFA_DEBUG__ 51 51 if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n ); 52 #endif // __CFA_DEBUG__52 #endif // __CFA_DEBUG__ 53 53 if ( last ) Next( last ) = &n; 54 54 else root = &n; 55 55 last = &n; 56 Next( &n ) = &n; 56 Next( &n ) = &n; // last node points to itself 57 57 } 58 58 … … 78 78 79 79 void remove( Queue(T) & q, T & n ) with( q ) { // O(n) 80 #ifdef __CFA_DEBUG__80 #ifdef __CFA_DEBUG__ 81 81 if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n ); 82 #endif // __CFA_DEBUG__82 #endif // __CFA_DEBUG__ 83 83 T * prev = 0p; 84 84 T * curr = (T *)root; … … 96 96 break; 97 97 } 98 #ifdef __CFA_DEBUG__99 98 // not found => error 100 if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n ); 101 #endif // __CFA_DEBUG__ 99 #ifdef __CFA_DEBUG__ 100 if ( curr == last ) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n ); 101 #endif // __CFA_DEBUG__ 102 102 prev = curr; 103 103 curr = Next( curr ); … … 125 125 // Node "n" must be in the "from" list. 126 126 void split( Queue(T) & q, Queue(T) & from, T & n ) with( q ) { 127 #ifdef __CFA_DEBUG__127 #ifdef __CFA_DEBUG__ 128 128 if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, &n ); 129 #endif // __CFA_DEBUG__129 #endif // __CFA_DEBUG__ 130 130 Queue(T) to; 131 131 to.root = from.root; // start of "to" list … … 177 177 } // distribution 178 178 } // distribution 179 180 // Local Variables: //181 // compile-command: "cfa queue.cfa" //182 // End: //
Note: See TracChangeset
for help on using the changeset viewer.