Chapter Index | Slide Index | Frames [ Windows ] | Narrative On | <- prev | next -> |

List Interface

public:
  // Terminology support
  typedef T                     ValueType;
  typedef ListIterator<T>       Iterator;
  typedef ConstListIterator<T>  ConstIterator;

  // Proper type
  List  ();                                 // default constructor
  ~List ();                                 // destructor
  List  (const List<T>& L);                 // copy constructor
  List<T>& operator =  (const List<T>& L);  // assignment operator

  // Modifying list structure
  bool         PushFront (const T& t);              // Insert t at front of list
  bool         PushBack  (const T& t);              // Insert t at back of list
  Iterator     Insert    (Iterator& i, const T& t); // Insert t at i
  bool         PopFront  ();                        // Remove the Tval at front
  bool         PopBack   ();                        // Remove the Tval at back
  Iterator     Remove    (Iterator& i);             // Remove item at i
  unsigned int Remove    (const T& t);              // Remove all copies of t
  void         Clear     ();                        // Empty the list

  // Information about the list
  unsigned int Size  () const; // return the number of elements on the list
  bool         Empty () const; // true iff list has no elements

  // Iterator support
  Iterator      Begin  ();        // return iterator at first element
  ConstIterator Begin  () const;  // const version
  Iterator      End    ();        // return iterator at first element
  ConstIterator End    () const;  // const version
  // ... plus decrement support with rBegin, rEnd

  T&       Front ();        // return reference to element at front of list
  const T& Front () const;  // const version
  T&       Back  ();        // return reference to element at back of list
  const T& Back  () const;  // const version

<- prev | next -> | Top of Page | 1. Positional Containers - 16 of 23