2 * Simple vector (Thread safe implementation)
7 #ifndef _CORELIB_COMMON_TS_VECTOR_H_
8 #define _CORELIB_COMMON_TS_VECTOR_H_
12 template <class T> class ITSVector
21 ITSVector() : count(0), capacity(32)
23 ary = new T*[capacity];
28 for (size_t i=0; i<count; ++i)
38 virtual void lock() = 0;
39 virtual void unlock() = 0;
41 virtual bool erase(size_t idx)
44 // for (size_t i=idx+1; i<count; ++i)
46 memmove(&ary[idx], &ary[idx+1], sizeof(T*) * (--count - idx));
53 for (size_t i=0; i<count; ++i)
62 virtual bool find(const T& tgt)
64 for (size_t i=0; i<count; ++i)
73 virtual bool find(const T& tgt, size_t* idx)
75 for (size_t i=0; i<count; ++i)
87 virtual bool push_back(const T& val)
91 if (count + 1 > capacity)
93 T **ptr = new T*[capacity * 2];
97 for (size_t i=0; i<capacity; ++i)
110 virtual T& at(size_t idx)
113 throw std::out_of_range("out of bounds");
118 virtual T& operator[](size_t idx)