Array.hh
Go to the documentation of this file.
00001 
00004 #ifndef P_ARRAY_HH
00005 #define P_ARRAY_HH
00006 
00007 #include <stdarg.h>
00008 #include <blort/Recognizer3D/PNamespace.hh>
00009 #include <blort/Recognizer3D/Except.hh>
00010 
00011 namespace P
00012 {
00013 
00020 template <class Elem> class Array
00021 {
00022 private:
00023   static const unsigned DEFAULT_SIZE = 10;
00024  
00025   Elem *array;        
00026   unsigned size;      
00027   unsigned capacity;  
00028 
00029   void CheckIndex(unsigned i) const throw(Except);
00030   void EnsureCapacity(unsigned need_size) throw(Except);
00031 
00032 public:
00033   Array(unsigned s = 0) throw(Except);
00034   Array(const Array &a);
00035   ~Array();
00036   Array& operator=(const Array &a) {DeepCopy(a); return *this;}
00037   Elem& operator[](unsigned i);
00038   const Elem& operator[](unsigned i) const;
00039   bool Empty() {return size == 0;}
00040   Elem& First() throw(Except);
00041   const Elem& First() const throw(Except);
00042   Elem& Last() throw(Except);
00043   const Elem& Last() const throw(Except);
00044   void PushFront(const Elem &el);
00045   void PushBack(const Elem &el);
00046   void InsertBefore(unsigned i, const Elem &el);
00047   void InsertAfter(unsigned i, const Elem &el);
00048   void InsertSorted(const Elem &el, int(*compar)(const void *, const void *));
00049   unsigned Size() const {return size;}
00050   void Resize(unsigned new_size);
00051   void Sort(int(*compar)(const void *, const void *));
00052   bool Contains(const Elem &el) const;
00053   bool ContainsBackwards(const Elem &el) const;
00054   unsigned Find(const Elem &el);
00055   unsigned Find(unsigned start, const Elem &el);
00056   unsigned FindBackwards(const Elem &el);
00057   void Swap(unsigned i, unsigned j);
00058   void Set(const Elem &el);
00059   void Clear() {Resize(0);}
00060   void DeepCopy(const Array &a);
00061   unsigned CircularNext(unsigned i);
00062   unsigned CircularPrev(unsigned i);
00063   void Erase(unsigned i);
00064   void EraseFirst();
00065   void EraseLast();
00066   void Reverse();
00067   bool Intersect(const Array &a);
00068   void* Data();
00069 };
00070 
00071 }
00072 
00073 #include "Array.ic"
00074 
00075 #endif
00076 


blort
Author(s): Thomas Mörwald , Michael Zillich , Andreas Richtsfeld , Johann Prankl , Markus Vincze , Bence Magyar
autogenerated on Wed Aug 26 2015 15:24:12