clean yet
This commit is contained in:
@@ -28,9 +28,6 @@
|
||||
#include "picontainers.h"
|
||||
|
||||
|
||||
#if !defined(PIP_CONTAINERS_STL) || defined(DOXYGEN)
|
||||
|
||||
|
||||
template <typename T>
|
||||
class PIVector {
|
||||
public:
|
||||
@@ -454,93 +451,6 @@ private:
|
||||
template<> inline PIVector<T> & PIVector<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
template<typename T, typename Allocator = std::allocator<T> >
|
||||
class PIP_EXPORT PIVector: public vector<T, Allocator> {
|
||||
typedef PIVector<T, Allocator> _CVector;
|
||||
typedef vector<T, Allocator> _stlc;
|
||||
public:
|
||||
|
||||
PIVector() {}
|
||||
PIVector(uint size, const T & value = T()) {_stlc::resize(size, value);}
|
||||
~PIVector() {}
|
||||
|
||||
const T & at(uint index) const {return (*this)[index];}
|
||||
T & at(uint index) {return (*this)[index];}
|
||||
const T * data(uint index = 0) const {return &(*this)[index];}
|
||||
T * data(uint index = 0) {return &(*this)[index];}
|
||||
|
||||
#ifdef DOXYGEN
|
||||
uint size() const;
|
||||
#endif
|
||||
|
||||
int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
bool isEmpty() const {return _stlc::empty();}
|
||||
bool has(const T & t) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) return true; return false;}
|
||||
int etries(const T & t) const {int ec = 0; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) ++ec; return ec;}
|
||||
|
||||
typedef int (*CompareFunc)(const T * , const T * );
|
||||
|
||||
static int compare_func(const T * t0, const T * t1) {return (*t0) == (*t1) ? 0 : ((*t0) < (*t1) ? -1 : 1);}
|
||||
#ifdef DOXYGEN
|
||||
|
||||
void resize(uint size, const T & new_type = T());
|
||||
PIVector<T, Allocator> & enlarge(uint size);
|
||||
void clear();
|
||||
PIVector<T, Allocator> & sort(CompareFunc compare = compare_func) {piqsort(&at(0), _stlc::size(), sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
|
||||
PIVector<T, Allocator> & fill(const T & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
T & back();
|
||||
const T & back() const;
|
||||
T & front();
|
||||
const T & front() const;
|
||||
PIVector<T, Allocator> & push_back(const T & t);
|
||||
PIVector<T, Allocator> & push_front(const T & t) {_stlc::insert(_stlc::begin(), t); return *this;}
|
||||
PIVector<T, Allocator> & pop_back();
|
||||
PIVector<T, Allocator> & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
|
||||
T take_back() {T t(_stlc::back()); _stlc::pop_back(); return t;}
|
||||
T take_front() {T t(_stlc::front()); pop_front(); return t;}
|
||||
PIVector<T, Allocator> & remove(uint index) {_stlc::erase(_stlc::begin() + index); return *this;}
|
||||
PIVector<T, Allocator> & remove(uint index, uint count) {_stlc::erase(_stlc::begin() + index, _stlc::begin() + index + count); return *this;}
|
||||
PIVector<T, Allocator> & removeOne(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); return *this;} return *this;}
|
||||
PIVector<T, Allocator> & removeAll(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); --i;} return *this;}
|
||||
PIVector<T, Allocator> & insert(uint pos, const T & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
PIVector<T, Allocator> & insert(uint pos, const PIVector<T, Allocator> & t) {_stlc::insert(_stlc::begin() + pos, t.begin(), t.end()); return *this;}
|
||||
T & operator [](uint index);
|
||||
const T & operator [](uint index) const;
|
||||
PIVector<T, Allocator> & operator <<(const T & t) {_stlc::push_back(t); return *this;}
|
||||
PIVector<T, Allocator> & operator <<(const PIVector<T, Allocator> & t) {for (typename _stlc::const_iterator i = t.begin(); i != t.end(); i++) _stlc::push_back(*i); return *this;}
|
||||
bool operator ==(const PIVector<T, Allocator> & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return false; return true;}
|
||||
bool operator !=(const PIVector<T, Allocator> & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return true; return false;}
|
||||
bool contains(const T & v) const {for (uint i = 0; i < _stlc::size(); ++i) if (v == at(i)) return true; return false;}
|
||||
|
||||
#else
|
||||
_CVector & enlarge(int size_) {int ns = size_s() + size_; if (ns <= 0) _stlc::clear(); else _stlc::resize(ns); return *this;}
|
||||
_CVector & sort(CompareFunc compare = compare_func) {piqsort(&at(0), _stlc::size(), sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
|
||||
_CVector & fill(const T & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
_CVector & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
|
||||
_CVector & push_front(const T & t) {_stlc::insert(_stlc::begin(), t); return *this;}
|
||||
T take_front() {T t(_stlc::front()); pop_front(); return t;}
|
||||
T take_back() {T t(_stlc::back()); _stlc::pop_back(); return t;}
|
||||
_CVector & remove(uint index) {_stlc::erase(_stlc::begin() + index); return *this;}
|
||||
_CVector & remove(uint index, uint count) {_stlc::erase(_stlc::begin() + index, _stlc::begin() + index + count); return *this;}
|
||||
_CVector & removeOne(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); return *this;} return *this;}
|
||||
_CVector & removeAll(const T & v) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (v == *i) {_stlc::erase(i); --i;} return *this;}
|
||||
_CVector & insert(uint pos, const T & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
_CVector & insert(uint pos, const _CVector & t) {_stlc::insert(_stlc::begin() + pos, t.begin(), t.end()); return *this;}
|
||||
_CVector & operator <<(const T & t) {_stlc::push_back(t); return *this;}
|
||||
_CVector & operator <<(const _CVector & t) {for (typename _stlc::const_iterator i = t.begin(); i != t.end(); i++) _stlc::push_back(*i); return *this;}
|
||||
bool operator ==(const _CVector & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return false; return true;}
|
||||
bool operator !=(const _CVector & t) {for (uint i = 0; i < _stlc::size(); ++i) if (t[i] != at(i)) return true; return false;}
|
||||
bool contains(const T & v) const {for (uint i = 0; i < _stlc::size(); ++i) if (v == at(i)) return true; return false;}
|
||||
#endif
|
||||
};
|
||||
|
||||
#define __PIVECTOR_SIMPLE_TYPE__(T)
|
||||
|
||||
|
||||
#endif
|
||||
__PIVECTOR_SIMPLE_TYPE__(bool)
|
||||
__PIVECTOR_SIMPLE_TYPE__(char)
|
||||
__PIVECTOR_SIMPLE_TYPE__(uchar)
|
||||
|
||||
Reference in New Issue
Block a user