[   ^ to index...   |   next -->   ]

CSE 143/AE : 13 July 2000


Linked lists

A linked list can be defined as either

The front of a list is commonly called its head, and the rest of the list is commonly called its tail (think of tadpoles, not dogs):

generic linked list diagram
struct ListNode { int value; ListNode * next; ListNode(int value) { this->value = value; } }; class LinkedList { public: LinkedList(); ~LinkedList(); // Destructor: ignore for now bool isEmpty(); // is the list empty? int length(); // returns the list length // Retrieves an item from the given position int valueAt(int position); // Inserts an item into the list at the given position void insert(int value, int position); // Removes the item at the given position from the list void removeAt(int position); private: ListNode * head; };

Last modified: Wed Jul 12 18:49:33 PDT 2000