Programming Resources
For Fun and Learning
Charles Cusack
Computer Science
Hope College
main

Python

C++


JAVA
PHP
SQL
Alice

LList


Description

Download zip file (Right click)
Download tar/gzip file (Right click)

Makefile
listtest.cpp
llist.cpp
llist.h

llist.h

// Linked List class.
// Stores positive integers.
//
typedef int keytype;

struct node {
keytype key;
node *next;
};

class llist {
public:
   llist();
   ~llist();
   llist(const llist &L);
   llist& operator =(const llist &L);

   void deallocate();

   void copy(const llist &L);


   bool insert_at_head(node *x);
   // Insert node at the head. Return 1 if successful, 0 otherwise.

   bool insert_after(node *y,node *x);
   // Insert node pointed to by x after node pointed to by y.
   // Return 1 if successful, 0 otherwise.

   keytype remove(node *x);
   // Remove the node pointed to by x.  
   // Return the key value of x if successful, -1 otherwise.

   keytype head_value();
   // Return the value of the key pointed to by head.

   node *find(keytype value);
   // Locate a value in the list.  Return a pointer to the first
   // node found with key=value, NULL if no such node exists.
private:
  node *head;
};