Ignore:
File:
1 edited

Legend:

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

    r768bd556 r92e7631  
    146146        static inline forall( dtype T | is_node(T) ) {
    147147                void ?{}( __queue(T) & this ) with( this ) {
    148                         head{ 0p };
     148                        head{ 1p };
    149149                        tail{ &head };
     150                        verify(*tail == 1p);
    150151                }
    151152
    152153                void append( __queue(T) & this, T * val ) with( this ) {
    153154                        verify(tail != 0p);
     155                        verify(*tail == 1p);
    154156                        *tail = val;
    155157                        tail = &get_next( *val );
     158                        *tail = 1p;
    156159                }
    157160
    158161                T * pop_head( __queue(T) & this ) {
     162                        verify(*this.tail == 1p);
    159163                        T * head = this.head;
    160                         if( head ) {
     164                        if( head != 1p ) {
    161165                                this.head = get_next( *head );
    162                                 if( !get_next( *head ) ) {
     166                                if( get_next( *head ) == 1p ) {
    163167                                        this.tail = &this.head;
    164168                                }
    165169                                get_next( *head ) = 0p;
    166                         }
    167                         return head;
     170                                verify(*this.tail == 1p);
     171                                verify( get_next(*head) == 0p );
     172                                return head;
     173                        }
     174                        verify(*this.tail == 1p);
     175                        return 0p;
    168176                }
    169177
     
    180188                        get_next( *val ) = 0p;
    181189
    182                         verify( (head == 0p) == (&head == tail) );
    183                         verify( *tail == 0p );
     190                        verify( (head == 1p) == (&head == tail) );
     191                        verify( *tail == 1p );
    184192                        return val;
    185193                }
     
    266274                        return this.head != 0;
    267275                }
     276
     277                void move_to_front( __dllist(T) & src, __dllist(T) & dst, T & node ) {
     278                        remove    (src, node);
     279                        push_front(dst, node);
     280                }
    268281        }
    269282        #undef next
Note: See TracChangeset for help on using the changeset viewer.