X-Git-Url: http://git.cinelerra-gg.org/git/?p=goodguy%2Fhistory.git;a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Flinklist.h;h=0c580defded3c95b8ff8836fbdf562c98ebd9792;hp=284a0ebfaeed2fc65eabf340c58a31853eb8d1a3;hb=04031cc2a664d2a6d9d2a37954c55cc68742d78c;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd diff --git a/cinelerra-5.1/guicast/linklist.h b/cinelerra-5.1/guicast/linklist.h index 284a0ebf..0c580def 100644 --- a/cinelerra-5.1/guicast/linklist.h +++ b/cinelerra-5.1/guicast/linklist.h @@ -7,18 +7,17 @@ template class ListItem { public: TYPE *previous, *next; - List *owner; + List *list; - int get_item_number() { return !owner ? -1 : owner->number_of(this); } - ListItem() { owner = 0; previous = next = 0; } - ListItem(List &me) { owner = me; previous = next = 0; } - virtual ~ListItem() { if( owner ) owner->remove_pointer(this); } + int get_item_number() { return !list ? -1 : list->number_of(this); } + ListItem() { list = 0; previous = next = 0; } + ListItem(List &me) { list = me; previous = next = 0; } + virtual ~ListItem() { if( list ) list->remove_pointer(this); } }; template class List { TYPE *split(int (*cmpr)(TYPE *a, TYPE *b),TYPE *l, TYPE *r); - void sort(int (*cmpr)(TYPE *a, TYPE *b),TYPE *ll, TYPE *rr); static int cmpr(TYPE *a, TYPE *b) { if( *a == *b ) return 0; return *a > *b ? 1 : -1; @@ -26,7 +25,7 @@ class List { public: TYPE *first, *last; void remove(TYPE *item) { if(item) delete item; } - void remove_pointer(ListItem *item); + void remove_pointer(ListItem *item); TYPE *append(TYPE *new_item); TYPE *append() { return append(new TYPE()); } TYPE *insert_before(TYPE *here, TYPE *item); @@ -44,8 +43,8 @@ public: return p ? i : -1; } void swap(TYPE *item1, TYPE *item2); - void sort(int (*cmp)(TYPE *a, TYPE *b) = 0) { - return sort(cmp ? cmp : cmpr,0,0); } + 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); List() { first = last = 0; } virtual ~List() { while(last) delete last; } }; @@ -57,7 +56,7 @@ public: template TYPE* List::append(TYPE *item) { - item->owner = this; item->next = 0; + item->list = this; item->next = 0; if( !last ) { item->previous = 0; first = item; } else { item->previous = last; last->next = item; } return last = item; @@ -67,7 +66,7 @@ template TYPE* List::insert_before(TYPE *here, TYPE *item) { if( !here || !last ) return append(item); - item->owner = this; item->next = here; + item->list = this; item->next = here; *( !(item->previous=here->previous) ? &first : &here->previous->next ) = item; return here->previous = item; } @@ -76,7 +75,7 @@ template TYPE* List::insert_after(TYPE *here, TYPE *item) { if( !here || !last ) return append(item); - item->owner = this; item->previous = here; + item->list = this; item->previous = here; *( !(item->next=here->next) ? &last : &here->next->previous ) = item; return here->next = item; } @@ -89,7 +88,7 @@ void List::remove_pointer(ListItem *item) TYPE *previous = item->previous, *next = item->next; *( previous ? &previous->next : &first ) = next; *( next ? &next->previous : &last ) = previous; - item->owner = 0; + item->list = 0; } template