Changes in libcfa/src/bits/sequence.hfa [7d4ce2a:8a81b09]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/sequence.hfa
r7d4ce2a r8a81b09 2 2 3 3 #include "bits/collection.hfa" 4 #include "bits/defs.hfa" 4 5 5 6 struct Seqable { 6 inline Colable;7 Seqable * back; // pointer to previous node in the list7 __cfa_anonymous_object(Colable); 8 struct Seqable * back; // pointer to previous node in the list 8 9 }; 9 10 10 inline { 11 #ifdef __cforall 12 static inline { 11 13 // PUBLIC 12 14 … … 26 28 } 27 29 28 // wrappers to make Collection have T29 forall( dtype T ) {30 T *& Back( T * n ) {31 return (T *)Back( (Seqable *)n );32 }33 } // distribution30 // // wrappers to make Collection have T 31 // forall( dtype T ) { 32 // T *& Back( T * n ) { 33 // return (T *)Back( (Seqable *)n ); 34 // } 35 // } // distribution 34 36 } // distribution 35 37 36 forall( dtype T ) {38 forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); bool listed ( T * ); } ) { 37 39 struct Sequence { 38 40 inline Collection; // Plan 9 inheritance 39 41 }; 40 42 41 inline {43 static inline { 42 44 // wrappers to make Collection have T 43 45 T & head( Sequence(T) & s ) with( s ) { … … 184 186 T * toEnd = Back( &head( s ) ); 185 187 T * fromEnd = Back( &head( from ) ); 186 Back( root ) = fromEnd;188 Back( (T *)root ) = fromEnd; 187 189 Next( fromEnd ) = &head( s ); 188 Back( from.root ) = toEnd;190 Back( (T *)from.root ) = toEnd; 189 191 Next( toEnd ) = &head( from ); 190 192 } // if … … 214 216 } // distribution 215 217 216 forall( dtype T ) {218 forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); bool listed ( T * ); } ) { 217 219 // SeqIter(T) is used to iterate over a Sequence(T) in head-to-tail order. 218 220 struct SeqIter { … … 224 226 }; 225 227 226 inline {228 static inline { 227 229 void ?{}( SeqIter(T) & si ) with( si ) { 228 230 ((ColIter &)si){}; … … 265 267 }; 266 268 267 inline {269 static inline { 268 270 void ?{}( SeqIterRev(T) & si ) with( si ) { 269 271 ((ColIter &)si){}; … … 298 300 } // distribution 299 301 } // distribution 302 303 #endif
Note: See TracChangeset
for help on using the changeset viewer.