Changeset 41cde266 for libcfa/src/bits/sequence.hfa
- Timestamp:
- Dec 17, 2020, 4:18:23 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 089b1a9a, f4f79dd
- Parents:
- c5a98f3 (diff), 68a867ee (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
-
libcfa/src/bits/sequence.hfa (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/sequence.hfa
rc5a98f3 r41cde266 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 * ); } ) { 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 * ); } ) { 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.