//----------------------------------------------------------------------
//  SPECIFICATION FILE (clist.h)
//  This module exports a class for maintaining lists of
//  single characters
//----------------------------------------------------------------------
#include "bool.h"

// DOMAIN: Each list is a collection of char values along with an
//         implicit list cursor in the range 1..n+1, where n is
//         the current length of the list

const int MAX_LENG = 100;

class CharList {
public:
    Boolean IsEmpty() const;
        // POST: FCTVAL == (list is empty)

    Boolean IsFull() const;
        // POST: FCTVAL == (list is full)

    void Reset();
        // PRE:  NOT IsEmpty()
        // POST: List cursor is at front of list

    Boolean EndOfList() const;
        // POST: FCTVAL == (list cursor is beyond end of list)

    void Advance();
        // PRE:  NOT IsEmpty()  &&  NOT EndOfList()
        // POST: List cursor has advanced to next item

    char CurrentItem() const;
        // PRE:  NOT IsEmpty()  &&  NOT EndOfList()
        // POST: FCTVAL == item at list cursor

    void InsertBefore( /* in */ char someChar );
        // PRE:  Assigned(someChar)  &&  NOT IsFull()
        // POST: someChar inserted before list cursor
        //          (at back, if EndOfList())
        //    && This is the new current item

    void InsertAfter( /* in */ char someChar );
        // PRE:  Assigned(someChar)  &&  NOT IsEmpty()
        //   &&  NOT IsFull()  &&  NOT EndOfList()
        // POST: someChar inserted after list cursor
        //    && This is the new current item

    void Delete();
        // PRE:  NOT IsEmpty()  &&  NOT EndOfList()
        // POST: Item at list cursor deleted
        //    && Successor of deleted item is now the current item

    CharList();
        // Constructor
        // POST: Empty list created  &&  EndOfList()
private:
    int  currPos;
    int  lastPos;
    char data[MAX_LENG];
};

