Ignore:
Timestamp:
Dec 8, 2020, 1:01:05 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:
8e58264
Parents:
33a129a (diff), c9e0991 (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

    r33a129a r3f91792  
    2828
    2929                T * succ( Queue(T) & q, T * n ) with( q ) {             // pre: *n in *q
    30 #ifdef __CFA_DEBUG__
     30                        #ifdef __CFA_DEBUG__
    3131                        if ( ! listed( n ) ) abort( "(Queue &)%p.succ( %p ) : Node is not on a list.", &q, n );
    32 #endif // __CFA_DEBUG__
     32                        #endif // __CFA_DEBUG__
    3333                        return (Next( n ) == n) ? 0p : Next( n );
    3434                } // post: n == tail() & succ(n) == 0 | n != tail() & *succ(n) in *q
    3535
    3636                void addHead( Queue(T) & q, T & n ) with( q ) {
    37 #ifdef __CFA_DEBUG__
     37                        #ifdef __CFA_DEBUG__
    3838                        if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n );
    39 #endif // __CFA_DEBUG__
     39                        #endif // __CFA_DEBUG__
    4040                        if ( last ) {
    4141                                Next( &n ) = &head( q );
     
    4343                        } else {
    4444                                root = last = &n;
    45                                 Next( &n ) = &n;                                                        // last node points to itself
     45                                Next( &n ) = &n;                                                // last node points to itself
    4646                        }
    4747                }
    4848
    4949                void addTail( Queue(T) & q, T & n ) with( q ) {
    50 #ifdef __CFA_DEBUG__
     50                        #ifdef __CFA_DEBUG__
    5151                        if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n );
    52 #endif // __CFA_DEBUG__
     52                        #endif // __CFA_DEBUG__
    5353                        if ( last ) Next( last ) = &n;
    5454                        else root = &n;
    5555                        last = &n;
    56                         Next( &n ) = &n;                                                                // last node points to itself
     56                        Next( &n ) = &n;                                                        // last node points to itself
    5757                }
    5858
     
    7878
    7979                void remove( Queue(T) & q, T & n ) with( q ) {  // O(n)
    80 #ifdef __CFA_DEBUG__
     80                        #ifdef __CFA_DEBUG__
    8181                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n );
    82 #endif // __CFA_DEBUG__
     82                        #endif // __CFA_DEBUG__
    8383                        T * prev = 0p;
    8484                        T * curr = (T *)root;
     
    9696                                        break;
    9797                                }
    98 #ifdef __CFA_DEBUG__
    9998                                // not found => error
    100                                 if (curr == last) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n );
    101 #endif // __CFA_DEBUG__
     99                                #ifdef __CFA_DEBUG__
     100                                if ( curr == last ) abort( "(Queue &)%p.remove( %p ) : Node is not in list.", &q, &n );
     101                                #endif // __CFA_DEBUG__
    102102                                prev = curr;
    103103                                curr = Next( curr );
     
    125125                // Node "n" must be in the "from" list.
    126126                void split( Queue(T) & q, Queue(T) & from, T & n ) with( q ) {
    127 #ifdef __CFA_DEBUG__
     127                        #ifdef __CFA_DEBUG__
    128128                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.split( %p ) : Node is not on a list.", &q, &n );
    129 #endif // __CFA_DEBUG__
     129                        #endif // __CFA_DEBUG__
    130130                        Queue(T) to;
    131131                        to.root = from.root;                                            // start of "to" list
     
    177177        } // distribution
    178178} // distribution
    179 
    180 // Local Variables: //
    181 // compile-command: "cfa queue.cfa" //
    182 // End: //
Note: See TracChangeset for help on using the changeset viewer.