Ignore:
Timestamp:
Dec 3, 2020, 11:56:01 AM (3 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:
89c982c, a78c3ff, cc5cc27
Parents:
1db306a
Message:

more code sharing in containers

File:
1 edited

Legend:

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

    r1db306a r636d3715  
    1414                        return (T *)head( (Collection &)q );
    1515                } // post: empty() & head() == 0 | !empty() & head() in *q
    16 
    17                 bool empty( Queue(T) & q ) with( q ) {                  // 0 <=> *q contains no elements
    18                         return empty( (Collection &)q );
    19                 }
    20 
    21                 bool listed( T * n ) {
    22                         return Next( (Colable *)n ) != 0;
    23                 }
    24 
    25                 T *& Next( T * n ) {
    26                         return (T *)Next( (Colable *)n );
    27                 }
    28 
    29                 T * Root( Queue(T) & q ) with( q ) {
    30                         return (T *)root;
    31                 }
    3216
    3317                void ?{}( Queue(T) &, const Queue(T) & ) = void; // no copy
     
    5539#endif // __CFA_DEBUG__
    5640                        if ( last ) {
    57                                 Next( n ) = Root( q );
     41                                Next( n ) = head( q );
    5842                                q.root = n;
    5943                        } else {
     
    8165                        if ( root ) {
    8266                                root = Next( root );
    83                                 if ( Root( q ) == t ) {
     67                                if ( head( q ) == t ) {
    8468                                        root = last = 0p;                                       // only one element
    8569                                }
     
    132116                                root = from.root;
    133117                        } else {                                                                        // "to" list not empty
    134                                 Next( last ) = Root( from );
     118                                Next( last ) = head( from );
    135119                        }
    136120                        last = from.last;
     
    148132                        to.last = n;                                                            // end of "to" list
    149133                        from.root = Next( n );                                          // start of "from" list
    150                         if ( n == Root( from ) ) {                                      // last node in list ?
     134                        if ( n == head( from ) ) {                                      // last node in list ?
    151135                                from.root = from.last = 0p;                             // mark "from" list empty
    152136                        } else {
     
    164148
    165149        inline {
    166                 // wrappers to make ColIter have T
    167                 T * Curr( QueueIter(T) & qi ) with( qi ) {
    168                         return (T *)curr;
    169                 }
    170 
    171150                void ?{}( QueueIter(T) & qi ) with( qi ) {
    172151                        ((ColIter &)qi){};
Note: See TracChangeset for help on using the changeset viewer.