// dl_list.h - header for a double-linked list implementation

#ifndef __dl_list_h__
#define __dl_list_h__

// the following typedef has to be here for struct _DLList_,
// although the node itself is private
typedef struct _DLListNode_ DLListNode;

typedef struct _DLList_ DLList;
typedef struct _DLListIterator_ DLListIterator;

// list and public (!!) access functions for it

struct _DLList_
{
  DLListNode *first;
  DLListNode *last;
};

DLList *newDLList();
void deleteDLList(DLList *list);

// iterator and access functions for it

struct _DLListIterator_
{
  DLList *list;
  DLListNode *current;
};

DLListIterator *newDLListIterator(DLList *list);
void deleteDLListIterator(DLListIterator *iterator);
void insertElementAfterCurrent(DLListIterator *iterator,
                               void *content);
void insertElementBeforeCurrent(DLListIterator *iterator,
                                void *content);
void deleteCurrentElement(DLListIterator *iterator);
void *setCurrentToFirstElement(DLListIterator *iterator);
void *setCurrentToLastElement(DLListIterator *iterator);
void *gotoNextElement(DLListIterator *iterator);
void *gotoPreviousElement(DLListIterator *iterator);
void *getCurrentElement(DLListIterator *iterator);

#endif // __dl_list_h__
