home *** CD-ROM | disk | FTP | other *** search
/ Informática Multimedia: Special Games / INFESPGAMES.mdf / os2 / ribble / support / cvector.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-08  |  1.7 KB  |  67 lines

  1. // -------------------------------
  2. //  $Source: C:\logical\store\classes/RCS/cvector.h,v $
  3. //  $Revision: 1.10 $
  4. //  $Date: 1993/11/09 17:45:41 $
  5. //  $Author: jason $
  6. //  Language:       C++
  7. //  Licence:        Public Domain
  8. //  Purpose:        Dynamically sized vectors
  9. // -------------------------------
  10.  
  11. #ifndef _CVector_h
  12. #define _CVector_h
  13.  
  14. #include "CAssert.h"
  15.  
  16. #ifndef C_NO_IOSTREAM
  17. #include <iostream.h>
  18. #endif
  19.  
  20. const int DEF_CHUNK_SIZE = 8;
  21.  
  22. template <class T>
  23. class CVector
  24. {
  25. public:
  26.   CVector();
  27.   CVector(const CVector<T>&);
  28.   CVector(const T);
  29.   CVector(const T huge*, unsigned long);
  30.   ~CVector();
  31.  
  32.   CVector<T>& operator=(const CVector<T>&);
  33.   CVector<T>& operator=(const T);
  34.   CVector<T>& operator+=(const CVector<T>&);
  35.   CVector<T>& operator+=(const T);
  36.   CVector<T>  operator+(const CVector<T>&) const;
  37.   int operator==(const CVector<T>&) const;
  38.   int operator!=(const CVector<T>&) const;
  39.   T& operator[](long index);
  40.  
  41.   unsigned long size() const       { return set ? (unsigned long)(upper - lower + 1L) : 0; }
  42.   unsigned long len() const        { return size(); }
  43.  
  44.   long   getLower(void) const { return set ? lower : 0; }
  45.   long   getUpper(void) const { return set ? upper : 0; }
  46.  
  47.   void setRange(long from, long to, T value);
  48.  
  49. private:
  50.   T huge*          data;   // array contents
  51.   short            set;    // data in array?
  52.   long             lower;  // effective lower bound
  53.   long             upper;  // effective upper bound
  54.   long             clb;    // real lower bound
  55.   long             cub;    // real upper bound;
  56.   long             chunk_size;
  57.  
  58.   long roundUp(long) const;
  59.   long roundDown(long) const;
  60. };
  61.  
  62. #ifndef _CSET2
  63. #include "CVector.c"
  64. #endif
  65.  
  66. #endif
  67.