home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch12 / intlist.h < prev    next >
C/C++ Source or Header  |  2005-06-16  |  2KB  |  70 lines

  1. //               intlist.h
  2. //
  3. // Contains a declaration of the intList class
  4. // for a list of integers.
  5.  
  6.  
  7. class intList {
  8. public:
  9.     intList();
  10.     // PRECONDITION: none.
  11.     //
  12.     // POSTCONDITION: an empty intList is constructed.
  13.  
  14.     ~intList();
  15.     // PRECONDITION:  none
  16.     //
  17.     // POSTCONDITION: the intList object is destroyed.
  18.  
  19.     bool insert( int elt, int position );
  20.     // PRECONDITION:  elt is to be inserted at position 
  21.     //                in the list. position should be a 
  22.     //                non-negative integer. A position of 0 denotes 
  23.     //                the front of the list.
  24.     //
  25.     // POSTCONDITION: The return value is true if the 
  26.     //                insertion was done at the prescribed 
  27.     //                position; false if elt could not be 
  28.     //                inserted at that position.
  29.  
  30.     bool remove( int elt );
  31.     // PRECONDITION:  elt is the integer that is to 
  32.     //                be removed from the intList object.
  33.     //
  34.     // POSTCONDITION: elt is not a list member. Return 
  35.     //                value is true if elt was removed 
  36.     //                from the list. Returns false if elt 
  37.     //                was not a member of the list.
  38.  
  39.     int search( int elt ) const;
  40.     // PRECONDITION:  elt is the integer to search for.
  41.     //
  42.     // POSTCONDITION: return value is the position in the 
  43.     //                list where elt was found or -1 if 
  44.     //                elt was not found.
  45.  
  46.     bool retrieve( int position, int& elt );
  47.     // PRECONDITION:  the integer at position is to be retrieved.
  48.     //
  49.     // POSTCONDITION: The return value is true and elt 
  50.     //                contains the list item that is at 
  51.     //                position in the list; the return value 
  52.     //                is false and elt is uninitialized if no 
  53.     //                item is at position in the list.
  54.  
  55.     bool IsFull() const;
  56.     // PRECONDITION:  none.
  57.     //
  58.     // POSTCONDITION: returns true is the List object
  59.     //                is full, false if not.
  60.  
  61.     bool IsEmpty() const;
  62.     // PRECONDITION:  none.
  63.     //
  64.     // POSTCONDITION: returns true if the List object
  65.     //                is empty; false, if not.
  66.  
  67. private:
  68.     // Private data members omitted.
  69. };
  70.