Ignore:
Timestamp:
Dec 28, 2020, 2:16:09 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:
28220d2
Parents:
b19fdb9 (diff), 1e6f632f (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

    rb19fdb9 ree56a4f  
    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                T & addHead( Queue(T) & q, T & n ) with( q ) {
    3737                        #ifdef __CFA_DEBUG__
    3838                        if ( listed( &n ) ) abort( "(Queue &)%p.addHead( %p ) : Node is already on another list.", &q, &n );
     
    4545                                Next( &n ) = &n;                                                // last node points to itself
    4646                        }
     47                        return n;
    4748                }
    4849
    49                 void addTail( Queue(T) & q, T & n ) with( q ) {
     50                T & addTail( Queue(T) & q, T & n ) with( q ) {
    5051                        #ifdef __CFA_DEBUG__
    5152                        if ( listed( &n ) ) abort( "(Queue &)%p.addTail( %p ) : Node is already on another list.", &q, &n );
     
    5556                        last = &n;
    5657                        Next( &n ) = &n;                                                        // last node points to itself
     58                        return n;
    5759                }
    5860
    59                 void add( Queue(T) & q, T & n ) with( q ) {
    60                         addTail( q, n );
     61                T & add( Queue(T) & q, T & n ) with( q ) {
     62                        return addTail( q, n );
    6163                }
    6264
     
    7779                }
    7880
    79                 void remove( Queue(T) & q, T & n ) with( q ) {  // O(n)
     81                T & remove( Queue(T) & q, T & n ) with( q ) {   // O(n)
    8082                        #ifdef __CFA_DEBUG__
    8183                        if ( ! listed( (Colable &)n ) ) abort( "(Queue &)%p.remove( %p ) : Node is not on a list.", &q, &n );
     
    103105                                curr = Next( curr );
    104106                        }
     107                        return n;
    105108                } // post: ! listed( n )
    106109
Note: See TracChangeset for help on using the changeset viewer.