X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Flinklist.h;h=3accf28153c2e13ed4eadcbf87ad76f1907da5ab;hb=0e6cf5b52d1ebce9272270144bcf43df4683507e;hp=0c580defded3c95b8ff8836fbdf562c98ebd9792;hpb=f068b73c1d4afafbf6d86e7f5bc8f1c96b5366d3;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/guicast/linklist.h b/cinelerra-5.1/guicast/linklist.h index 0c580def..3accf281 100644 --- a/cinelerra-5.1/guicast/linklist.h +++ b/cinelerra-5.1/guicast/linklist.h @@ -28,6 +28,7 @@ public: void remove_pointer(ListItem *item); TYPE *append(TYPE *new_item); TYPE *append() { return append(new TYPE()); } + void destroy() { while(last) delete last; } TYPE *insert_before(TYPE *here, TYPE *item); TYPE *insert_before(TYPE *here) { return insert_before(here, new TYPE()); } TYPE *insert_after(TYPE *here, TYPE *item); @@ -45,8 +46,9 @@ public: void swap(TYPE *item1, TYPE *item2); void sort(TYPE *ap=0, TYPE *bp=0) { return sort(cmpr,ap,bp); } void sort(int (*cmp)(TYPE *a, TYPE *b), TYPE *ap=0, TYPE *bp=0); + void concat(List &b); List() { first = last = 0; } - virtual ~List() { while(last) delete last; } + virtual ~List() { destroy(); } }; // convenience macros @@ -132,4 +134,14 @@ void List::sort(int (*cmpr)(TYPE *a, TYPE *b), TYPE *ll, TYPE *rr) } } +template +void List::concat(List &b) +{ + if( !b.first ) return; + *(last ? &last->next : &first) = b.first; + b.first->previous = last; last = b.last; + TYPE *bp = b.first; b.first = b.last = 0; + while( bp ) { bp->list = this; bp = bp->next; } +} + #endif