Changeset 1de50a9 for libcfa/src/bits/stack.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/stack.hfa
rcf2257f r1de50a9 10 10 inline { 11 11 // wrappers to make Collection have T 12 T *head( Stack(T) & s ) with( s ) {13 return (T *)head( (Collection &)s );12 T & head( Stack(T) & s ) with( s ) { 13 return *(T *)head( (Collection &)s ); 14 14 } // post: empty() & head() == 0 | !empty() & head() in *this 15 15 … … 22 22 23 23 T & top( Stack(T) & s ) with( s ) { 24 return *head( s );24 return head( s ); 25 25 } 26 26 … … 29 29 if ( listed( (Colable &)(n) ) ) abort( "(Stack &)%p.addHead( %p ) : Node is already on another list.", &s, n ); 30 30 #endif // __CFA_DEBUG__ 31 Next( &n ) = head( s ) ?head( s ) : &n;31 Next( &n ) = &head( s ) ? &head( s ) : &n; 32 32 root = &n; 33 33 } … … 42 42 43 43 T & drop( Stack(T) & s ) with( s ) { 44 T & t = *head( s );44 T & t = head( s ); 45 45 if ( root ) { 46 46 root = ( T *)Next(root); 47 if ( head( s ) == &t ) root = 0p; // only one element ?47 if ( &head( s ) == &t ) root = 0p; // only one element ? 48 48 Next( &t ) = 0p; 49 49 } // if … … 70 70 // create an iterator active in Stack s 71 71 void ?{}( StackIter(T) & si, Stack(T) & s ) with( si ) { 72 curr = head( s );72 curr = &head( s ); 73 73 } // post: curr = {e in s} 74 74 … … 79 79 // make existing iterator active in Stack q 80 80 void over( StackIter(T) & si, Stack(T) & s ) with( si ) { 81 curr = head( s );81 curr = &head( s ); 82 82 } // post: curr = {e in s} 83 83
Note: See TracChangeset
for help on using the changeset viewer.