Changeset a3a76ea for libcfa/src/bits/queue.hfa
- Timestamp:
- Dec 27, 2020, 5:55:50 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 62a7cc0
- Parents:
- 83c7e3c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/queue.hfa
r83c7e3c ra3a76ea 34 34 } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q 35 35 36 voidaddHead( Queue(T) & q, T & n ) with( q ) {36 T & addHead( Queue(T) & q, T & n ) with( q ) { 37 37 #ifdef __CFA_DEBUG__ 38 38 if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n ); … … 45 45 Next( &n ) = &n; // last node points to itself 46 46 } 47 return n; 47 48 } 48 49 49 voidaddTail( Queue(T) & q, T & n ) with( q ) {50 T & addTail( Queue(T) & q, T & n ) with( q ) { 50 51 #ifdef __CFA_DEBUG__ 51 52 if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n ); … … 55 56 last = &n; 56 57 Next( &n ) = &n; // last node points to itself 58 return n; 57 59 } 58 60 59 voidadd( Queue(T) & q, T & n ) with( q ) {60 addTail( q, n );61 T & add( Queue(T) & q, T & n ) with( q ) { 62 return addTail( q, n ); 61 63 } 62 64 … … 77 79 } 78 80 79 voidremove( Queue(T) & q, T & n ) with( q ) { // O(n)81 T & remove( Queue(T) & q, T & n ) with( q ) { // O(n) 80 82 #ifdef __CFA_DEBUG__ 81 83 if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n ); … … 103 105 curr = Next( curr ); 104 106 } 107 return n; 105 108 } // post: ! listed( n ) 106 109
Note: See TracChangeset
for help on using the changeset viewer.