Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/sequence.hfa

    rab1b971 r9536761  
    1 //
    2 // Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo
    3 //
    4 // The contents of this file are covered under the licence agreement in the
    5 // file "LICENCE" distributed with Cforall.
    6 //
    7 // bits/sequence.hfa -- PUBLIC
    8 // Intrusive doubly-linked list
    9 //
    10 // Author           : Colby Alexander Parsons & Peter A. Buhr
    11 // Created On       : Thu Jan 21 19:46:50 2021
    12 // Last Modified By :
    13 // Last Modified On :
    14 // Update Count     :
    15 //
    16 
    171#pragma once
    182
     
    226struct Seqable {
    237        __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
    269};
    2710
     
    4427                return sq->back;
    4528        }
     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
    4636} // distribution
    4737
     
    5343// and the back field of the last node points at the first node (circular).
    5444
    55 forall( T & ) {
     45forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); } ) {
    5646        struct Sequence {
    57                 // Plan 9 inheritance
    58                 inline Collection;
     47                inline Collection;                                                              // Plan 9 inheritance
    5948        };
    6049
    6150        static inline {
    62                 void ?{}( Sequence(T) &, const Sequence(T) & ) = void; // no copy
    63                 Sequence(T) & ?=?( const Sequence(T) & ) = void; // no assignment
    64 
    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 * ); }) {
    7151                // wrappers to make Collection have T
    7252                T & head( Sequence(T) & s ) with( s ) {
    7353                        return *(T *)head( (Collection &)s );
    7454                } // 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()
    7562
    7663                // Return a pointer to the last sequence element, without removing it.
     
    158145                        return n;
    159146                } // post: n->listed() & *n in *s & succ(n) == bef
    160 
     147               
    161148                // pre: n->listed() & *n in *s
    162149                T & remove( Sequence(T) & s, T & n ) with( s ) { // O(1)
     
    244231} // distribution
    245232
    246 forall( T & | { T *& Back ( T * ); T *& Next ( T * ); } ) {
     233forall( dtype T | { T *& Back ( T * ); T *& Next ( T * ); } ) {
    247234        // SeqIter(T) is used to iterate over a Sequence(T) in head-to-tail order.
    248235        struct SeqIter {
     
    298285
    299286        static inline {
    300                 void ?{}( SeqIterRev(T) & si ) with( si ) {
     287                void ?{}( SeqIterRev(T) & si ) with( si ) {     
    301288                        ((ColIter &)si){};
    302289                        seq = 0p;
     
    304291
    305292                // 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 ) {   
    307294                        ((ColIter &)si){};
    308295                        seq = &s;
     
    310297                } // post: elts = null
    311298
    312                 void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) {
     299                void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) { 
    313300                        ((ColIter &)si){};
    314301                        seq = &s;
Note: See TracChangeset for help on using the changeset viewer.