/* Implementacija skupa pomocu binarnih stabala */ static void AddToTree( Node *t, Node new ) { Node base; base = *t; /* Ako je stablo prazno, postavi objekat kao koren */ if ( base == NULL ) { *t = new; return; } else { if ( KeyLess( ItemKey( new->item ), ItemKey( base->item ) ) ) { AddToTree( &(base->left), new ); } else AddToTree( &(base->right), new ); } } void AddToCollection( Collection c, void *item ) { Node new, node_p; assert( c != NULL ); assert( item != NULL ); /* Alociraj memoriju za cvor za novi objekat */ new = (Node)malloc(sizeof(struct t_node)); /* Prikaci objekat na cvor */ new->item = item; new->left = new->right = (Node)0; AddToTree( &(c->node), new ); }