Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

std.h

Go to the documentation of this file.
00001 // std.h --
00002 // $Id: std.h,v 1.8 2004/02/16 15:55:55 jcw Exp $
00003 // This is part of Metakit, see https://www.equi4.com/metakit/
00004 
00009 #define q4_STD 1
00010 
00011 #include "mk4str.h"
00012 
00013 #include <vector>
00014 
00016 
00017 template<class T>
00018 class c4_ArrayT
00019 {
00020 #if defined(_MSC_VER) || defined(__BORLANDC__)
00021   d4_std::vector< T, d4_std::allocator<T> > _vector;
00022 #else
00023   d4_std::vector< T, d4_std::alloc > _vector;
00024 #endif
00025 
00026 public:
00027   c4_ArrayT ()              { }
00028   ~c4_ArrayT ()             { }
00029 
00030   int GetSize() const           { return _vector.size(); }
00031   void SetSize(int nNewSize, int =-1)   { _vector.resize(nNewSize); }
00032 
00033   T GetAt(int nIndex) const       { return _vector[nIndex]; }
00034   T& ElementAt(int nIndex)        { return _vector[nIndex]; }
00035 
00036   void SetAt(int nIndex, const T& newElement)
00037   {
00038     _vector[nIndex] = newElement;
00039   }
00040 
00041   int Add(const T& newElement)
00042   {
00043     int n = _vector.size();
00044     _vector.push_back(newElement);
00045     return n;
00046   }
00047 
00048   void InsertAt(int nIndex, const T& newElement, int nCount =1)
00049   {
00050     _vector.insert(&_vector[nIndex], nCount, newElement);
00051   }
00052 
00053   void RemoveAt(int nIndex, int nCount =1)
00054   {
00055     _vector.erase(&_vector[nIndex], &_vector[nIndex+nCount]);
00056   }
00057 };
00058 
00059 typedef c4_ArrayT<t4_i32>   c4_DWordArray;
00060 typedef c4_ArrayT<void*>    c4_PtrArray;
00061 typedef c4_ArrayT<c4_String>  c4_StringArray;
00062 


Metakit C++ API Reference - https://www.equi4.com/metakit.html - extracted with Doxygen