Ignore:
Timestamp:
Dec 2, 2020, 12:31:42 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
833ba13
Parents:
4f0c520
Message:

clean up all new collections and fix sequence iterator bug

File:
1 edited

Legend:

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

    r4f0c520 r3d0560d  
    116116
    117117                // 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 *s
     118                void insertAft( Sequence(T) & s, T * aft, T * n ) with( s ) {   // pre: !n->listed() & *aft in *s
    119119#ifdef __CFA_DEBUG__
    120120                        if ( listed( n ) ) abort( "(Sequence &)%p.insertAft( %p, %p ) : Node is already on another list.", &s, aft, n );
     
    145145               
    146146                // 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)
    148148#ifdef __CFA_DEBUG__
    149149                        if ( ! listed( n ) ) abort( "(Sequence &)%p.remove( %p ) : Node is not on a list.", &s, n );
     
    159159
    160160                // Add an element to the head of the sequence.
    161                 void addHead( Sequence(T) & s, T *n ) {                 // pre: !n->listed(); post: n->listed() & head() == n
     161                void addHead( Sequence(T) & s, T * n ) {                // pre: !n->listed(); post: n->listed() & head() == n
    162162                        insertAft( s, 0, n );
    163163                }
    164164                // Add an element to the tail of the sequence.
    165                 void addTail( Sequence(T) & s, T *n ) {                 // pre: !n->listed(); post: n->listed() & head() == n
     165                void addTail( Sequence(T) & s, T * n ) {                // pre: !n->listed(); post: n->listed() & head() == n
    166166                        insertBef( s, n, 0 );
    167167                }
    168168                // Add an element to the tail of the sequence.
    169                 void add( Sequence(T) & s, T *n ) {                             // pre: !n->listed(); post: n->listed() & head() == n
     169                void add( Sequence(T) & s, T * n ) {                    // pre: !n->listed(); post: n->listed() & head() == n
    170170                        addTail( s, n );
    171171                }
     
    244244                        ((ColIter &) si){};
    245245                        seq = &s;
     246                        curr = head( s );
    246247                } // post: elts = null.
    247248               
     
    251252                } // post: elts = {e in s}.
    252253
    253                 bool ?>>?( SeqIter(T) & si, T *& tp ) with( si ) {
     254                bool ?>>?( SeqIter(T) & si, T && tp ) with( si ) {
    254255                        if ( curr ) {
    255                                 tp = Curr( si );
    256                                 T *n = succ( *seq, Curr( si ) );
     256                                &tp = Curr( si );
     257                                T * n = succ( *seq, Curr( si ) );
    257258                                curr = n == head( *seq ) ? 0p : n;
    258                         } else tp = 0p;
    259                         return tp != 0p;
     259                        } else &tp = 0p;
     260                        return &tp != 0p;
    260261                }
    261262        } // distribution
     
    282283                        ((ColIter &) si){};
    283284                        seq = &s;
     285                        curr = tail( s );
    284286                } // post: elts = null.
    285287               
     
    289291                } // post: elts = {e in s}.
    290292
    291                 bool ?>>?( SeqIterRev(T) & si, T *&tp ) with( si ) {
     293                bool ?>>?( SeqIterRev(T) & si, T && tp ) with( si ) {
    292294                        if ( curr ) {
    293                                 tp = Curr( si );
    294                                 T *n = pred( *seq, Curr( si ) );
     295                                &tp = Curr( si );
     296                                T * n = pred( *seq, Curr( si ) );
    295297                                curr = n == tail( *seq ) ? 0p : n;
    296                         } else tp = 0p;
    297                         return tp != 0p;
     298                        } else &tp = 0p;
     299                        return &tp != 0p;
    298300                }
    299301        } // distribution
Note: See TracChangeset for help on using the changeset viewer.