Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Array.h

00001 //
00002 // Array.h
00003 //
00004 // Copyright (c) 2001 Virtual Terrain Project
00005 // Free for all uses, see license.txt for details.
00006 //
00007 
00008 #ifndef ARRAYH
00009 #define ARRAYH
00010 
00011 template <class E> class Array
00012 {
00013 public:
00014     Array(int size = 0);
00015     Array(const Array<E>&);
00016     virtual ~Array();
00017 
00018 //  Accessors
00019     int     GetSize() const;
00020     int     GetMaxSize() const;
00021     bool    SetSize(int);
00022     bool    SetMaxSize(int);
00023     int     GetElemSize() const;
00024     E*      GetData() const;
00025     bool    IsEmpty() const;
00026     E&      GetAt(int i) const;
00027     bool    SetAt(int, E);
00028 
00029 //  Other operations
00030     Array<E>& operator=(const Array<E>&);
00031     E&          operator[](int i);
00032     const E&    operator[](int i) const;
00033     void        Empty();
00034     bool        RemoveAt(int i, int n = 1);
00035     int     Append(const E&);
00036     int     Append(const Array<E>&);
00037     int     Find(const E&) const;
00038 
00039 protected:
00040 //  Internal functions
00041     virtual bool    Grow(int);
00042     virtual void    ConstructItems(int first, int last);
00043     virtual void    DestructItems(int first, int last);
00044 
00045 //  Data members
00046     int     m_Size;     // number of elements added so far
00047     int     m_MaxSize;  // maximum number of elements we have room for
00048     E*      m_Data;     // data area for array
00049 };
00050 
00051 #endif

Generated at Fri Aug 17 14:40:42 2001 for vtdata library by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000