CS 24000 Lecture Notes - Lecture 21: Linked List, C String Handling, Sentinel Node

160 views5 pages

Document Summary

Cs 240 lecture 21 03302017- double linked list. Adding a node at the beginning of a double linked list. #define dlist_h struct dlistnode{ char * name; void * value; struct dlistnode * next; struct dlistnode * previous; class dlist { int nelements; Dlist(); void print(void); void addfront(char * name, void * value); void * lookup(char * name); int removefront(char * name); // but simplifies the list implementation. head = new dlistnode(); nelements = 0; head->next = head; head->previous = head; Implementing a double-linked list void dlist::addfront(char * name, void * value) { Dlistnode * e = new dlistnode(); e->name = strdup(name); e->value = value; //add at the beginning e->next = head->next; e->previous = head; e->next->previous = e; e->previous->next = e; nelements++; Adding at the end of a double linked list. Implementing a double-linked list void dlist::addend(char * name, void * value) {

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents