/* list.h 
 *
 * A list with elements of type Person.
 *
 * new Lnode()                    create a node
 * new Lnode( Person *data )      create a node, fill with "ldata"
 * Lnode.data                     the data field of the node
 *
 * new list()                     create an empty list
 * list.empty()                   1 if list is empty, 0 otherwise
 * list.head()                    ptr to head node of list
 * list.next( Lnode * )         ptr to next node on list
 * list.add_to_head( Lnode * )  add a node before the list head
 * list.add_to_tail( Lnode * )  add a node after the list tail
 * list.remove( Lnode * )       remove node from list, but don't delete node
 * list.remove_all()             discard all the list nodes
 * list.member( Lnode * )       1 if node is in list, 0 otherwise

 * list.add_data( T data )        add a node containing data to the list tail
 * list.remove_data( T data )     remove the node containing data from the list
 */


#ifndef LIST_H
#define LIST_H


#include <stdio.h>
#include <iostream.h>

class Person;

class Lnode {

    friend class List;
private:
  
    Lnode* prev;
    Lnode* next;

public:
    //Lnode *sentinel;

    Person *data;

    Lnode()       { next = NULL; }
    Lnode(Person *item) { next = NULL; data = item; }
};


class List {

private:

    Lnode   * sentinel;
  
    void      add_to_head( Lnode * );
    void      add_to_tail( Lnode * );
    void      remove( Lnode * );
    void      remove_all();
 
public:

    int       empty();
//    Lnode   * head();
    Lnode   * get_next( Lnode * );
    void      print();
  
    void      add_data( Person *data );
    void      remove_data( Person *data );

    List();   
    ~List()   { remove_all(); }
};


#endif

