// ----------------------------------------------------------------------
 //
 // File: list.h
 //
 // This module implements a List class for integers.
 // The module is inteded for CTA++ demonstation purposes only.
 // Copyright (c) 1998-2002 Testwell Oy
 //
 // Last edited: 12.12.2002
 //
 // ----------------------------------------------------------------------
 
 // ----------------------------------------------------------------------
 // First some exception classes
 // ----------------------------------------------------------------------
 
 class Exception {};
 class ExceptionEmptyList : public Exception {};
 
 class ExceptionIteratorOutOfBounds : public Exception {
 public:
     ExceptionIteratorOutOfBounds(const char* msg) : message(msg) {}
     const char* getMsg() const { return message; }
 private:
     const char* message;
 };
 
 class ExceptionItemNotFound : public Exception {};
 class ExceptionOutOfMemory  : public Exception {};
 
 // a couple of forward declarations
 class List_iterator;
 class List_reverse_iterator;
 
 // the initial size of the list
 const int LIST_STEP = 16;
 
 // ----------------------------------------------------------------------
 // Class List
 // ----------------------------------------------------------------------
 
 class List {
 public:
                            List();
                            ~List();
     void                   insert(int t);
     int                    extract();
     void                   remove(int t);
     List_iterator          begin() const ;
     List_iterator          last() const ;
     List_reverse_iterator  rbegin() const;
     bool                   empty() const;
     int                    itemCount() const;
 
 private:
 
     int*                   last_element;
     int*                   the_list;
     int                    item_count;
     int                    list_size;
     
     friend class           List_iterator;
     friend class           List_reverse_iterator;
 
 }; // class List
 
 
 // ----------------------------------------------------------------------
 // An iterator class to the actual List class
 // ----------------------------------------------------------------------
 
 class List_iterator {
 public:
     // public methods of the class
                     List_iterator(const List* l);
                     List_iterator(const List* l, int* iter);
     bool            end() const;
     int             operator*();
     List_iterator&  operator++();
 
 private:
 
     int*            iter_list;
     const List*     list;
 };
 
 
 // ----------------------------------------------------------------------
 // A reverse iterator class to the actual List class
 // ----------------------------------------------------------------------
 
 class List_reverse_iterator {
 public:
                             List_reverse_iterator(const List* l);
                             List_reverse_iterator(const List* l, int* iter);
     bool                    rend();
     int                     operator*();
     List_reverse_iterator&  operator--();
 
 private:
 
     const List*             list;
     int*                    iter_list;
 };
 
 // EOF