Changeset 54f89d5 for libcfa/src/bits


Ignore:
Timestamp:
Dec 4, 2020, 11:39:23 AM (5 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:
3c6480b7
Parents:
ab0257b9 (diff), a32cbac2 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
libcfa/src/bits
Files:
1 added
5 edited

Legend:

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

    rab0257b9 r54f89d5  
    1717#include "bits/align.hfa"
    1818#include "bits/defs.hfa"
    19 
     19#include <stdio.h>
    2020//-----------------------------------------------------------------------------
    2121// Array
     
    146146        static inline forall( dtype T | is_node(T) ) {
    147147                void ?{}( __queue(T) & this ) with( this ) {
    148                         head{ 1p };
    149                         tail{ &head };
    150                         verify(*tail == 1p);
     148                        (this.head){ 1p };
     149                        (this.tail){ &this.head };
     150                        verify(*this.tail == 1p);
    151151                }
    152152
    153153                void append( __queue(T) & this, T * val ) with( this ) {
    154                         verify(tail != 0p);
    155                         verify(*tail == 1p);
    156                         *tail = val;
    157                         tail = &get_next( *val );
    158                         *tail = 1p;
     154                        verify(this.tail != 0p);
     155                        verify(*this.tail == 1p);
     156                        *this.tail = val;
     157                        this.tail = &get_next( *val );
     158                        *this.tail = 1p;
    159159                }
    160160
    161161                T * peek( __queue(T) & this ) {
    162162                        verify(*this.tail == 1p);
    163                         T * head = this.head;
    164                         if( head != 1p ) {
     163                        T * front = this.head;
     164                        if( front != 1p ) {
    165165                                verify(*this.tail == 1p);
    166                                 return head;
     166                                return front;
    167167                        }
    168168                        verify(*this.tail == 1p);
     
    172172                T * pop_head( __queue(T) & this ) {
    173173                        verify(*this.tail == 1p);
    174                         T * head = this.head;
    175                         if( head != 1p ) {
    176                                 this.head = get_next( *head );
    177                                 if( get_next( *head ) == 1p ) {
     174                        T * _head = this.head;
     175                        if( _head != 1p ) {
     176                                this.head = get_next( *_head );
     177                                if( get_next( *_head ) == 1p ) {
    178178                                        this.tail = &this.head;
    179179                                }
    180                                 get_next( *head ) = 0p;
     180                                get_next( *_head ) = 0p;
    181181                                verify(*this.tail == 1p);
    182                                 verify( get_next(*head) == 0p );
    183                                 return head;
     182                                verify( get_next(*_head) == 0p );
     183                                return _head;
    184184                        }
    185185                        verify(*this.tail == 1p);
     
    193193                        (*it) = get_next( *val );
    194194
    195                         if( tail == &get_next( *val ) ) {
    196                                 tail = it;
     195                        if( this.tail == &get_next( *val ) ) {
     196                                this.tail = it;
    197197                        }
    198198
    199199                        get_next( *val ) = 0p;
    200200
    201                         verify( (head == 1p) == (&head == tail) );
    202                         verify( *tail == 1p );
     201                        verify( (this.head == 1p) == (&this.head == this.tail) );
     202                        verify( *this.tail == 1p );
    203203                        return val;
    204204                }
     
    239239        forall(dtype T )
    240240        static inline [void] ?{}( __dllist(T) & this, * [T * & next, T * & prev] ( T & ) __get ) {
    241                 this.head{ 0p };
     241                (this.head){ 0p };
    242242                this.__get = __get;
    243243        }
     
    248248                void push_front( __dllist(T) & this, T & node ) with( this ) {
    249249                        verify(__get);
    250                         if ( head ) {
    251                                 __get( node ).next = head;
    252                                 __get( node ).prev = __get( *head ).prev;
     250                        if ( this.head ) {
     251                                __get( node ).next = this.head;
     252                                __get( node ).prev = __get( *this.head ).prev;
    253253                                // inserted node must be consistent before it is seen
    254254                                // prevent code movement across barrier
    255255                                asm( "" : : : "memory" );
    256                                 __get( *head ).prev = &node;
     256                                __get( *this.head ).prev = &node;
    257257                                T & _prev = *__get( node ).prev;
    258258                                __get( _prev ).next = &node;
     
    264264                        // prevent code movement across barrier
    265265                        asm( "" : : : "memory" );
    266                         head = &node;
     266                        this.head = &node;
    267267                }
    268268
    269269                void remove( __dllist(T) & this, T & node ) with( this ) {
    270270                        verify(__get);
    271                         if ( &node == head ) {
    272                                 if ( __get( *head ).next == head ) {
    273                                         head = 0p;
     271                        if ( &node == this.head ) {
     272                                if ( __get( *this.head ).next == this.head ) {
     273                                        this.head = 0p;
    274274                                } else {
    275                                         head = __get( *head ).next;
     275                                        this.head = __get( *this.head ).next;
    276276                                }
    277277                        }
  • libcfa/src/bits/queue.hfa

    rab0257b9 r54f89d5  
    1111        inline {
    1212                // wrappers to make Collection have T
    13                 T * head( Queue(T) & q ) with( q ) {
    14                         return (T *)head( (Collection &)q );
     13                T & head( Queue(T) & q ) with( q ) {
     14                        return *(T *)head( (Collection &)q );
    1515                } // post: empty() & head() == 0 | !empty() & head() in *q
    1616
     
    2323                } // post: empty()
    2424
    25                 T * tail( Queue(T) & q ) with( q ) {
    26                         return last;
     25                T & tail( Queue(T) & q ) with( q ) {
     26                        return *last;
    2727                }
    2828
     
    3434                } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q
    3535
    36                 void addHead( Queue(T) & q, T * n ) with( q ) {
     36                void addHead( Queue(T) & q, T & n ) with( q ) {
    3737#ifdef __CFA_DEBUG__
    38                         if ( listed( n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, n );
     38                        if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n );
    3939#endif // __CFA_DEBUG__
    4040                        if ( last ) {
    41                                 Next( n ) = head( q );
    42                                 q.root = n;
     41                                Next( &n ) = &head( q );
     42                                q.root = &n;
    4343                        } else {
    44                                 root = last = n;
    45                                 Next( n ) = n;                                                  // last node points to itself
     44                                root = last = &n;
     45                                Next( &n ) = &n;                                                        // last node points to itself
    4646                        }
    4747                }
    4848
    49                 void addTail( Queue(T) & q, T * n ) with( q ) {
     49                void addTail( Queue(T) & q, T & n ) with( q ) {
    5050#ifdef __CFA_DEBUG__
    51                         if ( listed( n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, n );
     51                        if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n );
    5252#endif // __CFA_DEBUG__
    53                         if ( last ) Next( last ) = n;
    54                         else root = n;
    55                         last = n;
    56                         Next( n ) = n;                                                          // last node points to itself
     53                        if ( last ) Next( last ) = &n;
     54                        else root = &n;
     55                        last = &n;
     56                        Next( &n ) = &n;                                                                // last node points to itself
    5757                }
    5858
    59                 void add( Queue(T) & q, T * n ) with( q ) {
     59                void add( Queue(T) & q, T & n ) with( q ) {
    6060                        addTail( q, n );
    6161                }
    6262
    63                 T * dropHead( Queue(T) & q ) with( q ) {
    64                         T * t = head( q );
     63                T & dropHead( Queue(T) & q ) with( q ) {
     64                        T & t = head( q );
    6565                        if ( root ) {
    6666                                root = Next( root );
    67                                 if ( head( q ) == t ) {
     67                                if ( &head( q ) == &t ) {
    6868                                        root = last = 0p;                                       // only one element
    6969                                }
    70                                 Next( t ) = 0p;
     70                                Next( &t ) = 0p;
    7171                        }
    7272                        return t;
    7373                }
    7474
    75                 T * drop( Queue(T) & q ) with( q ) {
     75                T & drop( Queue(T) & q ) with( q ) {
    7676                        return dropHead( q );
    7777                }
    7878
    79                 void remove( Queue(T) & q, T * n ) with( q ) {  // O(n)
     79                void remove( Queue(T) & q, T & n ) with( q ) {  // O(n)
    8080#ifdef __CFA_DEBUG__
    81                         if ( ! listed( (Colable &)(*n) ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, n );
     81                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n );
    8282#endif // __CFA_DEBUG__
    83                         T * prev = 0;
     83                        T * prev = 0p;
    8484                        T * curr = (T *)root;
    8585                        for ( ;; ) {
    86                                 if (n == curr) {                                                // found => remove
    87                                         if ((T *)root == n) {
     86                                if ( &n == curr ) {                                             // found => remove
     87                                        if ( (T *)root == &n ) {
    8888                                                dropHead( q );
    89                                         } else if (last == n) {
     89                                        } else if ( last == &n ) {
    9090                                                last = prev;
    9191                                                Next( last ) = last;
     
    9393                                                Next( prev ) = Next( curr );
    9494                                        }
    95                                         Next( n ) = 0p;
     95                                        Next( &n ) = 0p;
    9696                                        break;
    9797                                }
    9898#ifdef __CFA_DEBUG__
    9999                                // not found => error
    100                                 if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, n );
     100                                if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n );
    101101#endif // __CFA_DEBUG__
    102102                                prev = curr;
     
    105105                } // post: ! listed( n )
    106106
    107                 T * dropTail( Queue(T) & q ) with( q ) { // O(n)
    108                         T * n = tail( q );
    109                         return n ? remove( q, n ), n : 0p;
     107                T & dropTail( Queue(T) & q ) with( q ) { // O(n)
     108                        T & n = tail( q );
     109                        return &n ? remove( q, n ), n : *0p;
    110110                }
    111111
     
    116116                                root = from.root;
    117117                        } else {                                                                        // "to" list not empty
    118                                 Next( last ) = head( from );
     118                                Next( last ) = &head( from );
    119119                        }
    120120                        last = from.last;
     
    124124                // Transfer the "from" list up to node "n" to the end of queue list; the "from" list becomes the list after node "n".
    125125                // Node "n" must be in the "from" list.
    126                 void split( Queue(T) & q, Queue(T) & from, T * n ) with( q ) {
     126                void split( Queue(T) & q, Queue(T) & from, T & n ) with( q ) {
    127127#ifdef __CFA_DEBUG__
    128                         if ( ! listed( (Colable &)(*n) ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, n );
     128                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, &n );
    129129#endif // __CFA_DEBUG__
    130130                        Queue(T) to;
    131131                        to.root = from.root;                                            // start of "to" list
    132                         to.last = n;                                                            // end of "to" list
    133                         from.root = Next( n );                                          // start of "from" list
    134                         if ( n == head( from ) ) {                                      // last node in list ?
     132                        to.last = &n;                                                           // end of "to" list
     133                        from.root = Next( &n );                                         // start of "from" list
     134                        if ( &n == &head( from ) ) {                            // last node in list ?
    135135                                from.root = from.last = 0p;                             // mark "from" list empty
    136136                        } else {
    137                                 Next( n ) = n;                                                  // fix end of "to" list
     137                                Next( &n ) = &n;                                                // fix end of "to" list
    138138                        }
    139139                        transfer( q, to );
     
    154154                // create an iterator active in Queue q
    155155                void ?{}( QueueIter(T) & qi, Queue(T) & q ) with( qi ) {
    156                         curr = head( q );
     156                        curr = &head( q );
    157157                } // post: curr = {e in q}
    158158
    159                 void ?{}( QueueIter(T) & qi, T * start ) with( qi ) {
    160                         curr = start;
     159                void ?{}( QueueIter(T) & qi, T & start ) with( qi ) {
     160                        curr = &start;
    161161                } // post: curr = {e in q}
    162162
    163163                // make existing iterator active in Queue q
    164164                void over( QueueIter(T) & qi, Queue(T) & q ) with( qi ) {
    165                         curr = head( q );
     165                        curr = &head( q );
    166166                } // post: curr = {e in q}
    167167
     
    179179
    180180// Local Variables: //
    181 // compile-command: "make install" //
     181// compile-command: "cfa queue.cfa" //
    182182// End: //
  • libcfa/src/bits/queue_example.cfa

    rab0257b9 r54f89d5  
    2727       
    2828        for ( i; 10 ) {
    29                 add( fred, new( 2 * i ) );
     29                add( fred, *new( 2 * i ) );
    3030        }
    3131
     
    3636
    3737        for ( i; 9 ) {
    38                 delete( drop( fred ) );
     38                delete( &drop( fred ) );
    3939        }
    4040
     
    4545       
    4646        for ( i; 10 ) {
    47                 add( fred, new( 2 * i + 1 ) );
     47                add( fred, *new( 2 * i + 1 ) );
    4848        }
    4949        for ( over( fredIter, fred ); fredIter >> f; ) {
     
    7878       
    7979        for ( i; 10 ) {
    80                 add( mary, new( 2 * i ) );
     80                add( mary, *new( 2 * i ) );
    8181        }
    8282
     
    8787       
    8888        for ( i; 9 ) {
    89                 delete( drop( mary ) );
     89                delete( &drop( mary ) );
    9090        }
    9191
     
    9696       
    9797        for ( i; 10 ) {
    98                 add( mary, new( 2 * i + 1 ) );
     98                add( mary, *new( 2 * i + 1 ) );
    9999        }
    100100        for ( over( maryIter, mary ); maryIter >> m; ) {
  • libcfa/src/bits/sequence.hfa

    rab0257b9 r54f89d5  
    1414        } // post: ! listed()
    1515
    16         Seqable * getBack( Seqable & sq ) with( sq ) {
    17                 return back;
     16        Seqable & getBack( Seqable & sq ) with( sq ) {
     17                return *back;
    1818        }
    1919
     
    3030        inline {
    3131                // wrappers to make Collection have T
    32                 T * head( Sequence(T) & s ) with( s ) {
    33                         return (T *)head( (Collection &)s );
     32                T & head( Sequence(T) & s ) with( s ) {
     33                        return *(T *)head( (Collection &)s );
    3434                } // post: empty() & head() == 0 | !empty() & head() in *s
    3535
     
    4747                // Return a pointer to the last sequence element, without removing it. 
    4848                T & tail( Sequence(T) & s ) with( s ) {
    49                         return root ? (T &)Back( head( s ) ) : *0p;     // needs cast?
     49                        return root ? (T &)*Back( &head( s ) ) : *0p;
    5050                }       // post: empty() & tail() == 0 | !empty() & tail() in *s
    5151
     
    5555                        if ( ! listed( n ) ) abort( "(Sequence &)%p.succ( %p ) : Node is not on a list.", &s, n );
    5656#endif // __CFA_DEBUG__
    57                         return Next( n ) == head( s ) ? 0p : Next( n );
    58                 }       // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *s
     57                        return Next( n ) == &head( s ) ? 0p : Next( n );
     58                } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *s
    5959
    6060                // Return a pointer to the element before *n, or 0p if there isn't one.
     
    6363                        if ( ! listed( n ) ) abort( "(Sequence &)%p.pred( %p ) : Node is not on a list.", &s, n );
    6464#endif // __CFA_DEBUG__
    65                         return n == head( s ) ? 0p : Back( n );
     65                        return n == &head( s ) ? 0p : Back( n );
    6666                }       // post: n == head() & head(n) == 0 | n != head() & *pred(n) in *s
    6767
     
    7272                        if ( listed( &n ) ) abort( "(Sequence &)%p.insertBef( %p, %p ) : Node is already on another list.", &s, n, &bef );
    7373#endif // __CFA_DEBUG__
    74                         if ( &bef == head( s ) ) {                                      // must change root
     74                        if ( &bef == &head( s ) ) {                                     // must change root
    7575                                if ( root ) {
    76                                         Next( &n ) = head( s );
    77                                         Back( &n ) = Back( head( s ) );
     76                                        Next( &n ) = &head( s );
     77                                        Back( &n ) = Back( &head( s ) );
    7878                                        // inserted node must be consistent before it is seen
    7979                                        asm( "" : : : "memory" );                       // prevent code movement across barrier
    80                                         Back( head( s ) ) = &n;
     80                                        Back( &head( s ) ) = &n;
    8181                                        Next( Back( &n ) ) = &n;
    8282                                } else {
     
    8888                                root = &n;
    8989                        } else {
    90                                 if ( ! &bef ) &bef = head( s );
     90                                if ( ! &bef ) &bef = &head( s );
    9191                                Next( &n ) = &bef;
    9292                                Back( &n ) = Back( &bef );
     
    106106                        if ( ! &aft ) {                                                         // must change root
    107107                                if ( root ) {
    108                                         Next( &n ) = head( s );
    109                                         Back( &n ) = Back( head( s ) );
     108                                        Next( &n ) = &head( s );
     109                                        Back( &n ) = Back( &head( s ) );
    110110                                        // inserted node must be consistent before it is seen
    111111                                        asm( "" : : : "memory" );                       // prevent code movement across barrier
    112                                         Back( head( s ) ) = &n;
     112                                        Back( &head( s ) ) = &n;
    113113                                        Next( Back( &n ) ) = &n;
    114114                                } else {
     
    133133                        if ( ! listed( &n ) ) abort( "(Sequence &)%p.remove( %p ) : Node is not on a list.", &s, &n );
    134134#endif // __CFA_DEBUG__
    135                         if ( &n == head( s ) ) {
    136                                 if ( Next( head( s ) ) == head( s ) ) root = 0p;
    137                                 else root = Next( head(s ) );
     135                        if ( &n == &head( s ) ) {
     136                                if ( Next( &head( s ) ) == &head( s ) ) root = 0p;
     137                                else root = Next( &head( s ) );
    138138                        } // if
    139139                        Back( Next( &n ) ) = Back( &n );
     
    156156                // Remove and return the head element in the sequence.
    157157                T & dropHead( Sequence(T) & s ) {
    158                         T * n = head( s );
    159                         return n ? remove( s, *n ), *n : *0p;
     158                        T & n = head( s );
     159                        return &n ? remove( s, n ), n : *0p;
    160160                }
    161161                // Remove and return the head element in the sequence.
     
    175175                                root = from.root;
    176176                        } else {                                                                        // "to" list not empty
    177                                 T * toEnd = Back( head( s ) );
    178                                 T * fromEnd = Back( head( from ) );
     177                                T * toEnd = Back( &head( s ) );
     178                                T * fromEnd = Back( &head( from ) );
    179179                                Back( root ) = fromEnd;
    180                                 Next( fromEnd ) = head( s );
     180                                Next( fromEnd ) = &head( s );
    181181                                Back( from.root ) = toEnd;
    182                                 Next( toEnd ) = head( from );
     182                                Next( toEnd ) = &head( from );
    183183                        } // if
    184184                        from.root = 0p;                                                         // mark "from" list empty
     
    187187                // Transfer the "from" list up to node "n" to the end of s list; the "from" list becomes the sequence after node "n".
    188188                // Node "n" must be in the "from" list.
    189                 void split( Sequence(T) & s, Sequence(T) & from, T * n ) with( s ) {
    190 #ifdef __CFA_DEBUG__
    191                         if ( ! listed( n ) ) abort( "(Sequence &)%p.split( %p ) : Node is not on a list.", &s, n );
     189                void split( Sequence(T) & s, Sequence(T) & from, T & n ) with( s ) {
     190#ifdef __CFA_DEBUG__
     191                        if ( ! listed( &n ) ) abort( "(Sequence &)%p.split( %p ) : Node is not on a list.", &s, &n );
    192192#endif // __CFA_DEBUG__
    193193                        Sequence(T) to;
    194194                        to.root = from.root;                                            // start of "to" list
    195                         from.root = Next( n );                                          // start of "from" list
     195                        from.root = Next( &n );                                         // start of "from" list
    196196                        if ( to.root == from.root ) {                           // last node in list ?
    197197                                from.root = 0p;                                                 // mark "from" list empty
    198198                        } else {
    199                                 Back( head( from ) ) = Back( head( to ) ); // fix "from" list
    200                                 Next( Back( head( to ) ) ) = head( from );
    201                                 Next( n ) = head( to );                                 // fix "to" list
    202                                 Back( head( to ) ) = n;
     199                                Back( &head( from ) ) = Back( &head( to ) ); // fix "from" list
     200                                Next( Back( &head( to ) ) ) = &head( from );
     201                                Next( &n ) = &head( to );                                       // fix "to" list
     202                                Back( &head( to ) ) = &n;
    203203                        } // if
    204204                        transfer( s, to );
     
    211211        struct SeqIter {
    212212                inline ColIter;
     213                // The Sequence must be passed to pred and succ to check for the end of the Sequence and return 0p. Without
     214                // passing the sequence, traversing would require its length. Thus the iterator needs a pointer to the sequence
     215                // to pass to succ/pred. Both stack and queue just encounter 0p since the lists are not circular.
    213216                Sequence(T) * seq;
    214217        };
     
    223226                        ((ColIter &) si){};
    224227                        seq = &s;
    225                         curr = head( s );
    226                 } // post: elts = null.
    227                
     228                        curr = &head( s );
     229                } // post: elts = null.
     230
     231                void ?{}( SeqIter(T) & si, Sequence(T) & s, T & start ) with( si ) {
     232                        ((ColIter &) si){};
     233                        seq = &s;
     234                        curr = &start;
     235                } // post: elts = null.
     236
    228237                void over( SeqIter(T) & si, Sequence(T) & s ) with( si ) {
    229238                        seq = &s;
    230                         curr = head( s );
     239                        curr = &head( s );
    231240                } // post: elts = {e in s}.
    232241
     
    235244                                &tp = Curr( si );
    236245                                T * n = succ( *seq, Curr( si ) );
    237                                 curr = n == head( *seq ) ? 0p : n;
     246                                curr = n == &head( *seq ) ? 0p : n;
    238247                        } else &tp = 0p;
    239248                        return &tp != 0p;
     
    245254        struct SeqIterRev {
    246255                inline ColIter;
     256                // See above for explanation.
    247257                Sequence(T) * seq;
    248258        };
     
    259269                        curr = &tail( s );
    260270                } // post: elts = null.
    261                
     271
     272                void ?{}( SeqIterRev(T) & si, Sequence(T) & s, T & start ) with( si ) {
     273                        ((ColIter &) si){};
     274                        seq = &s;
     275                        curr = &start;
     276                } // post: elts = null.
     277
    262278                void over( SeqIterRev(T) & si, Sequence(T) & s ) with( si ) {
    263279                        seq = &s;
     
    277293
    278294// Local Variables: //
    279 // compile-command: "make install" //
     295// compile-command: "cfa sequence.hfa" //
    280296// End: //
  • libcfa/src/bits/stack.hfa

    rab0257b9 r54f89d5  
    1010        inline {
    1111                // wrappers to make Collection have T
    12                 T * head( Stack(T) & s ) with( s ) {
    13                         return (T *)head( (Collection &)s );
     12                T & head( Stack(T) & s ) with( s ) {
     13                        return *(T *)head( (Collection &)s );
    1414                } // post: empty() & head() == 0 | !empty() & head() in *this
    1515
     
    2222
    2323                T & top( Stack(T) & s ) with( s ) {
    24                         return *head( s );
     24                        return head( s );
    2525                }
    2626
     
    2929                        if ( listed( (Colable &)(n) ) ) abort( "(Stack &)%p.addHead( %p ) : Node is already on another list.", &s, n );
    3030#endif // __CFA_DEBUG__
    31                         Next( &n ) = head( s ) ? head( s ) : &n;
     31                        Next( &n ) = &head( s ) ? &head( s ) : &n;
    3232                        root = &n;
    3333                }
     
    4242
    4343                T & drop( Stack(T) & s ) with( s ) {
    44                         T & t = *head( s );
     44                        T & t = head( s );
    4545                        if ( root ) {
    4646                                root = ( T *)Next(root);
    47                                 if ( head( s ) == &t ) root = 0p;               // only one element ?
     47                                if ( &head( s ) == &t ) root = 0p;              // only one element ?
    4848                                Next( &t ) = 0p;
    4949                        } // if
     
    7070                // create an iterator active in Stack s
    7171                void ?{}( StackIter(T) & si, Stack(T) & s ) with( si ) {
    72                         curr = head( s );
     72                        curr = &head( s );
    7373                } // post: curr = {e in s}
    7474
     
    7979                // make existing iterator active in Stack q
    8080                void over( StackIter(T) & si, Stack(T) & s ) with( si ) {
    81                         curr = head( s );
     81                        curr = &head( s );
    8282                } // post: curr = {e in s}
    8383
Note: See TracChangeset for help on using the changeset viewer.