/* removeFrontList param: lst the linkedList pre:lst is not null pre: lst is not empty post: size is reduced by 1 */ void removeFrontList(struct linkedList *lst) { /* FIXME: you must write this */ assert(lst != 0); assert(lst->size != 0); //Remove lst->firstLink->next _removeLink(lst, lst->firstLink->next); }
/* Remove the front of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the front is removed from the deque */ void removeFrontCirListDeque (struct cirListDeque *q) { /* FIXME: you must write this */ /* q is not null and q is not empty is asserted in _removeLink */ /* send what comes AFTER the sentinel */ _removeLink(q, q->Sentinel->next); }
/* Remove the front of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the front is removed from the deque */ void removeFrontCirListDeque (struct cirListDeque *q) { /* FIXME: you must write this */ assert(q != 0); assert(!isEmptyCirListDeque(q)); _removeLink(q, q->Sentinel->next); }
void removeBackList(struct linkedList *lst) { assert(lst != NULL); assert(lst->size != 0); _removeLink(lst, lst->lastLink->prev); }
/* Remove the back of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the back is removed from the deque */ void removeBackCirListDeque(struct cirListDeque *q) { /* DONE: you must write this */ assert(q != 0 && !isEmptyCirListDeque(q)); _removeLink(q, q->Sentinel->prev); }
/* Remove the back of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the back is removed from the deque */ void removeBackCirListDeque(struct cirListDeque *q) { /* FIXME: you must write this */ /*q is not null and q is not empty is asserted in _removeLink */ /* send what comes BEFORE the sentinel */ _removeLink(q, q->Sentinel->prev); }
/* removeBackList param: lst the linkedList pre: lst is not null pre:lst is not empty post: size reduced by 1 */ void removeBackList(struct linkedList *lst) { /* FIXME: you must write this */ assert(lst!=NULL); assert(!isEmptyList(lst)); _removeLink(lst,lst->lastLink->prev); }
/* Remove the back of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the back is removed from the deque */ void removeBackCirListDeque(struct cirListDeque *q) { /* FIXME: you must write this */ assert(q != NULL); assert(q->size != 0); _removeLink(q, q->Sentinel->prev); }
void removeFrontList(struct linkedList *lst) { _removeLink(lst, lst->firstLink->next); /* FIXME: you must write this */ }
/* removeFrontList param: lst the linkedList pre:lst is not null pre: lst is not empty post: size is reduced by 1 */ void removeFrontList(struct linkedList *lst) { /* FIXME: you must write this */ // printf("list size: %d", lst->size); assert(!isEmptyList(lst)); _removeLink(lst,lst->firstLink->next); }
void removeFrontList(struct linkedList *lst) { /* FIXME: you must write this */ assert(lst != NULL); assert(!isEmptyList(lst)); _removeLink(lst, lst->firstLink->next); }
/* removeBackList param: lst the linkedList pre: lst is not null pre:lst is not empty post: size reduced by 1 */ void removeBackList(struct linkedList *lst) { /* FIXME: you must write this */ assert(lst != 0); assert(lst->size != 0); //Remove lst->lastLink->prev _removeLink(lst, lst->lastLink->prev); }
void _freeLinkedList(struct linkedList *lst) { struct DLink *cur = lst->frontSentinel->next; while(cur != lst->backSentinel) { _removeLink(lst,cur); } }
void removeFrontList(struct linkedList *lst) { assert(lst != 0); //make sure lst contains a valid address if (!isEmptyList(lst)) { _removeLink(lst, lst->firstLink->next); //remove link from the front of the list } }
void removeBackList(struct linkedList *lst) { assert(lst != 0); //make sure lst contains a valid address if (!isEmptyList(lst)) { _removeLink(lst, lst->lastLink->prev); //remove link from the back of the list } }
/* De-allocate all links of the list param: lst pointer to the linked list pre: none post: All links (including the two sentinels) are de-allocated */ void freeLinkedList(struct linkedList *lst) { while(!isEmptyList(lst)) { /* remove the link right after the first sentinel */ _removeLink(lst, lst->firstLink->next); } /* remove the first and last sentinels */ free(lst->firstLink); free(lst->lastLink); }
/* Remove the back of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the back is removed from the deque */ void removeBackCirListDeque(struct cirListDeque *q) { //make sure q is not null assert(!EQ(q, 0)); //make sure q is not empty assert(!isEmptyCirListDeque(q)); //remove the last link _removeLink(q, q->Sentinel->prev); }
/* De-allocate all links of the deque param: q pointer to the deque pre: none post: All links (including Sentinel) are de-allocated */ void freeCirListDeque(struct cirListDeque *q) { /* FIXME: you must write this */ struct DLink* temp = q->Sentinel->next; while (temp != q->Sentinel) { _removeLink(q, temp); temp = q->Sentinel->next; } free(temp); }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e) { DLink *start = lst->firstLink->next; // iterate over whole list (other than sentinels) // if value == e encountered, delete link with // that value for( ; start != lst->lastLink; start = start->next) if(start->value == e) { _removeLink(lst, start); break; } }
/* Remove the front of the deque param: q pointer to the deque pre: q is not null and q is not empty post: the front is removed from the deque */ void removeFrontCirListDeque (struct cirListDeque *q) { //make sure q is not null assert(!EQ(q, 0)); //make sure q is not empty assert(!isEmptyCirListDeque(q)); //remove the first link _removeLink(q, q->Sentinel->next); }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e) { /* FIXME: you must write this */ assert(lst!=NULL); if(!isEmptyList(lst)){ struct DLink *current = lst->firstLink; while(current!=lst->lastLink){ if(current->value == e){ _removeLink(lst,current); } current=current->next; } } }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e) { /* FIXME: you must write this */ assert(lst != 0); assert(!isEmptyList(lst)); struct DLink *current = lst->firstLink->next; while (current != lst->lastLink) { if (EQ(current->value, e)); { _removeLink(lst, current); break; } current = current->next; } }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e) { struct DLink * conductor = (struct DLink *) malloc(sizeof(struct DLink)); conductor = lst->firstLink->next; while(conductor->next != 0) { if(conductor->value == e) { _removeLink(lst, conductor); } else { conductor = conductor->next; } } }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e) { struct DLink *printer = malloc(sizeof(struct DLink)); printer->next = lst->firstLink->next; for (int i = 0; i < lst->size; i++) { if (printer->next->value == e) { _removeLink(lst, printer->next); } printer->next = printer->next->next; } free(printer); }
/* De-allocate all links of the deque param: q pointer to the deque pre: none post: All links (including Sentinel) are de-allocated */ void freeCirListDeque(struct cirListDeque *q) { /* FIXME: you must write this */ struct DLink * temp = q->Sentinel->next; struct DLink * forwardLink = temp->next; while (forwardLink != q->Sentinel) { temp = forwardLink->next; _removeLink(q, forwardLink); forwardLink = temp; } free(q); }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e){ struct DLink *current = lst->firstLink->next; assert(lst); assert(! isEmptyList(lst)); while(current->next != lst->lastLink){ current = current->next; if(current->value == e) { _removeLink(lst, current); return; } } return; }
/* Removes the first occurrence of the specified value from the collection if it occurs param: lst pointer to the bag param: e the value to be removed from the bag pre: lst is not null pre: lst is not empty post: e has been removed post: size of the bag is reduced by 1 */ void removeList (struct linkedList *lst, TYPE e) { assert(lst != NULL); assert( !isEmptyList(lst) ); // couldn't think of a way to reuse containsList() struct DLink* i = lst->firstLink; // placeholder // traverse list while (i != lst->lastLink) { if ( i->value == e ) _removeLink(lst,i); else i = i->next; } }
int linkedListRemove( struct linkedList *lst, TYPE e ) { assert( lst != NULL ); struct dlink *tmp_lnk = lst->frontSentinel; while( tmp_lnk->next != NULL ) { /* We have found the link to remove */ if( tmp_lnk->value == e ) { _removeLink( lst, tmp_lnk ); } tmp_lnk = tmp_lnk->next; } return( 0 ); }
/* Iterative implementation of remove() Pre: lst is not null pre: lst is not empty */ void removeList (struct linkedList *lst, TYPE e) { //create a temp var struct DLink * check = malloc(sizeof(struct DLink)); assert(check != 0); //INITIALIZE IT check = lst->firstLink->next; while(check != lst->lastLink){ if(check->value == e){ _removeLink(lst, check); free(check); return; } check = check->next; } printf("Error; value not found"); //if you love me let me go free(check); }
/* Iterative implementation of remove() Pre: lst is not null pre: lst is not empty */ void removeList (struct linkedList *lst, TYPE e) { assert(lst != NULL); assert(lst->size != 0); int removed = FALSE; struct DLink *tempLink = lst->firstLink; int index = 0; while((removed == FALSE) &&(index < lst->size)) { if(tempLink->next->value == e){ _removeLink(lst, tempLink->next); removed = TRUE; }else{ index++; tempLink = tempLink->next; } } }