Changes in libcfa/src/bits/sequence.hfa [3d0560d:5e82d56]
- File:
-
- 1 edited
-
libcfa/src/bits/sequence.hfa (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/sequence.hfa
r3d0560d r5e82d56 116 116 117 117 // Insert *n into the sequence after *aft, or at the beginning if aft == 0. 118 void insertAft( Sequence(T) & s, T * aft, T *n ) with( s ) { // pre: !n->listed() & *aft in *s118 void insertAft( Sequence(T) & s, T *aft, T *n ) with( s ) { // pre: !n->listed() & *aft in *s 119 119 #ifdef __CFA_DEBUG__ 120 120 if ( listed( n ) ) abort( "(Sequence &)%p.insertAft( %p, %p ) : Node is already on another list.", &s, aft, n ); … … 145 145 146 146 // pre: n->listed() & *n in *s 147 void remove( Sequence(T) & s, T * n ) with( s ) { // O(1)147 void remove( Sequence(T) & s, T *n ) with( s ) { // O(1) 148 148 #ifdef __CFA_DEBUG__ 149 149 if ( ! listed( n ) ) abort( "(Sequence &)%p.remove( %p ) : Node is not on a list.", &s, n ); … … 159 159 160 160 // Add an element to the head of the sequence. 161 void addHead( Sequence(T) & s, T * n ) {// pre: !n->listed(); post: n->listed() & head() == n161 void addHead( Sequence(T) & s, T *n ) { // pre: !n->listed(); post: n->listed() & head() == n 162 162 insertAft( s, 0, n ); 163 163 } 164 164 // Add an element to the tail of the sequence. 165 void addTail( Sequence(T) & s, T * n ) {// pre: !n->listed(); post: n->listed() & head() == n165 void addTail( Sequence(T) & s, T *n ) { // pre: !n->listed(); post: n->listed() & head() == n 166 166 insertBef( s, n, 0 ); 167 167 } 168 168 // Add an element to the tail of the sequence. 169 void add( Sequence(T) & s, T * n ) {// pre: !n->listed(); post: n->listed() & head() == n169 void add( Sequence(T) & s, T *n ) { // pre: !n->listed(); post: n->listed() & head() == n 170 170 addTail( s, n ); 171 171 } … … 244 244 ((ColIter &) si){}; 245 245 seq = &s; 246 curr = head( s );247 246 } // post: elts = null. 248 247 … … 252 251 } // post: elts = {e in s}. 253 252 254 bool ?>>?( SeqIter(T) & si, T && tp ) with( si ) {253 bool ?>>?( SeqIter(T) & si, T *& tp ) with( si ) { 255 254 if ( curr ) { 256 &tp = Curr( si );257 T * n = succ( *seq, Curr( si ) );255 tp = Curr( si ); 256 T *n = succ( *seq, Curr( si ) ); 258 257 curr = n == head( *seq ) ? 0p : n; 259 } else &tp = 0p;260 return &tp != 0p;258 } else tp = 0p; 259 return tp != 0p; 261 260 } 262 261 } // distribution … … 283 282 ((ColIter &) si){}; 284 283 seq = &s; 285 curr = tail( s );286 284 } // post: elts = null. 287 285 … … 291 289 } // post: elts = {e in s}. 292 290 293 bool ?>>?( SeqIterRev(T) & si, T &&tp ) with( si ) {291 bool ?>>?( SeqIterRev(T) & si, T *&tp ) with( si ) { 294 292 if ( curr ) { 295 &tp = Curr( si );296 T * n = pred( *seq, Curr( si ) );293 tp = Curr( si ); 294 T *n = pred( *seq, Curr( si ) ); 297 295 curr = n == tail( *seq ) ? 0p : n; 298 } else &tp = 0p;299 return &tp != 0p;296 } else tp = 0p; 297 return tp != 0p; 300 298 } 301 299 } // distribution
Note:
See TracChangeset
for help on using the changeset viewer.