home *** CD-ROM | disk | FTP | other *** search
/ PC Media 7 / PC MEDIA CD07.iso / share / prog / cm / cmtvec.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-06  |  1.6 KB  |  41 lines

  1. // CmTVec.h
  2. // -----------------------------------------------------------------
  3. // Compendium - C++ Container Class Library
  4. // Copyright (C) 1992-1994, Glenn M. Poorman, All rights reserved
  5. // -----------------------------------------------------------------
  6. // Dynamic array template definition.
  7. // -----------------------------------------------------------------
  8.  
  9. #ifndef _CMTVEC_H
  10. #define _CMTVEC_H
  11.  
  12. #include <cm/include/cmdefs.h>
  13.  
  14. template <class T> class CmTVector {              // Vector definition.
  15. public:
  16.   CmTVector(unsigned = 0);                        // Default constructor.
  17.   CmTVector(const CmTVector<T>&);                 // Copy constructor.
  18.  ~CmTVector();                                    // List destructor.
  19.  
  20.   CmTVector<T>& operator= (const CmTVector<T>&);  // Assignment operator.
  21.  
  22.   unsigned size      () const;                    // Return number of objs.
  23.   T*       array     () const;                    // Return array pointer.
  24.   T&       operator[](int);                       // Set or get an object.
  25.   const T& operator[](int) const;                 // Get an object.
  26.   void     clear     ();                          // Clear the list.
  27.   Bool     resize    (unsigned);                  // Resize the list.
  28.  
  29. protected:
  30.   void copy(const CmTVector<T>&);                 // Internal copy method.
  31.  
  32.   unsigned _size;                                 // Number of objects.
  33.   T       *_array;                                // Array of objects.
  34. };
  35.  
  36. #if defined(__TURBOC__) || defined(__xlC__)
  37. #include <cm/include/cmtvec.cc>
  38. #endif
  39.  
  40. #endif
  41.