Ignore:
Timestamp:
Dec 3, 2020, 8:58:29 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
032fd93
Parents:
cf2257f (diff), 7b2a786 (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

File:
1 edited

Legend:

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

    rcf2257f r1de50a9  
    2727                }
    2828
    29                 T & succ( Queue(T) & q, T & n ) with( q ) {             // pre: *n in *q
     29                T * succ( Queue(T) & q, T * n ) with( q ) {             // pre: *n in *q
    3030#ifdef __CFA_DEBUG__
    31                         if ( ! listed( &n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, &n );
     31                        if ( ! listed( n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, n );
    3232#endif // __CFA_DEBUG__
    33                         return (Next( &n ) == &n) ? *0p : *Next( &n );
     33                        return (Next( n ) == n) ? 0p : Next( n );
    3434                } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q
    3535
     
    6262
    6363                T & dropHead( Queue(T) & q ) with( q ) {
    64                         T * t = &head( 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                        }
    72                         return *t;
     72                        return t;
    7373                }
    7474
     
    8181                        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;
     
    132132                        to.last = &n;                                                           // end of "to" list
    133133                        from.root = Next( &n );                                         // start of "from" list
    134                         if ( &n == &head( from ) ) {                                    // last node in 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 );
     
    179179
    180180// Local Variables: //
    181 // compile-command: "make install" //
     181// compile-command: "cfa queue.cfa" //
    182182// End: //
Note: See TracChangeset for help on using the changeset viewer.