Changes in libcfa/src/bits/sequence.hfa [ab1b971:9536761]
- File:
-
- 1 edited
-
libcfa/src/bits/sequence.hfa (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/sequence.hfa
rab1b971 r9536761 1 //2 // Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // bits/sequence.hfa -- PUBLIC8 // Intrusive doubly-linked list9 //10 // Author : Colby Alexander Parsons & Peter A. Buhr11 // Created On : Thu Jan 21 19:46:50 202112 // Last Modified By :13 // Last Modified On :14 // Update Count :15 //16 17 1 #pragma once 18 2 … … 22 6 struct Seqable { 23 7 __cfa_anonymous_object(Colable); 24 // pointer to previous node in the list 25 struct Seqable * back; 8 struct Seqable * back; // pointer to previous node in the list 26 9 }; 27 10 … … 44 27 return sq->back; 45 28 } 29 30 // // wrappers to make Collection have T 31 // forall( dtype T ) { 32 // T *& Back( T * n ) { 33 // return (T *)Back( (Seqable *)n ); 34 // } 35 // } // distribution 46 36 } // distribution 47 37 … … 53 43 // and the back field of the last node points at the first node (circular). 54 44 55 forall( T &) {45 forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); } ) { 56 46 struct Sequence { 57 // Plan 9 inheritance 58 inline Collection; 47 inline Collection; // Plan 9 inheritance 59 48 }; 60 49 61 50 static inline { 62 void ?{}( Sequence(T) &, const Sequence(T) & ) = void; // no copy63 Sequence(T) & ?=?( const Sequence(T) & ) = void; // no assignment64 65 void ?{}( Sequence(T) & s ) with( s ) {66 ((Collection &)s){};67 } // post: isEmpty()68 }69 70 static inline forall(| { T *& Back ( T * ); T *& Next ( T * ); }) {71 51 // wrappers to make Collection have T 72 52 T & head( Sequence(T) & s ) with( s ) { 73 53 return *(T *)head( (Collection &)s ); 74 54 } // post: empty() & head() == 0 | !empty() & head() in *s 55 56 void ?{}( Sequence(T) &, const Sequence(T) & ) = void; // no copy 57 Sequence(T) & ?=?( const Sequence(T) & ) = void; // no assignment 58 59 void ?{}( Sequence(T) & s ) with( s ) { 60 ((Collection &)s){}; 61 } // post: isEmpty() 75 62 76 63 // Return a pointer to the last sequence element, without removing it. … … 158 145 return n; 159 146 } // post: n->listed() & *n in *s & succ(n) == bef 160 147 161 148 // pre: n->listed() & *n in *s 162 149 T & remove( Sequence(T) & s, T & n ) with( s ) { // O(1) … … 244 231 } // distribution 245 232 246 forall( T &| { T *& Back ( T * ); T *& Next ( T * ); } ) {233 forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); } ) { 247 234 // SeqIter(T) is used to iterate over a Sequence(T) in head-to-tail order. 248 235 struct SeqIter { … … 298 285 299 286 static inline { 300 void ?{}( SeqIterRev(T) & si ) with( si ) { 287 void ?{}( SeqIterRev(T) & si ) with( si ) { 301 288 ((ColIter &)si){}; 302 289 seq = 0p; … … 304 291 305 292 // Create a iterator active in sequence s. 306 void ?{}( SeqIterRev(T) & si, Sequence(T) & s ) with( si ) { 293 void ?{}( SeqIterRev(T) & si, Sequence(T) & s ) with( si ) { 307 294 ((ColIter &)si){}; 308 295 seq = &s; … … 310 297 } // post: elts = null 311 298 312 void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) { 299 void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) { 313 300 ((ColIter &)si){}; 314 301 seq = &s;
Note:
See TracChangeset
for help on using the changeset viewer.