04.11.2011 - adjust for Windows & QNX, multiprotocol, repeater, signals, process, codec, console input
This commit is contained in:
228
picontainers.h
228
picontainers.h
@@ -63,27 +63,27 @@ struct _PIForeachBase {mutable bool _break;};
|
||||
template<typename Type>
|
||||
class _PIForeach: public _PIForeachBase {
|
||||
public:
|
||||
inline _PIForeach(Type & t, bool i = false): _t(t), _inv(i) {if (_inv) _rit = _t.rbegin(); else _it = _t.begin(); _break = false;}
|
||||
_PIForeach(Type & t, bool i = false): _t(t), _inv(i) {if (_inv) _rit = _t.rbegin(); else _it = _t.begin(); _break = false;}
|
||||
mutable typename Type::value_type _var;
|
||||
mutable typename Type::iterator _it;
|
||||
mutable typename Type::reverse_iterator _rit;
|
||||
Type & _t;
|
||||
bool _inv;
|
||||
inline bool isEnd() {if (_inv) return _rit == _t.rend(); else return _it == _t.end();}
|
||||
inline void operator ++() {if (_inv) _rit++; else _it++; _break = false;}
|
||||
bool isEnd() {if (_inv) return _rit == _t.rend(); else return _it == _t.end();}
|
||||
void operator ++() {if (_inv) _rit++; else _it++; _break = false;}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class _PIForeachC: public _PIForeachBase {
|
||||
public:
|
||||
inline _PIForeachC(const Type & t, bool i = false): _t(t), _inv(i) {if (_inv) _rit = _t.rbegin(); else _it = _t.begin(); _break = false;}
|
||||
_PIForeachC(const Type & t, bool i = false): _t(t), _inv(i) {if (_inv) _rit = _t.rbegin(); else _it = _t.begin(); _break = false;}
|
||||
mutable typename Type::value_type _var;
|
||||
mutable typename Type::const_iterator _it;
|
||||
mutable typename Type::const_reverse_iterator _rit;
|
||||
const Type & _t;
|
||||
bool _inv;
|
||||
inline bool isEnd() {if (_inv) return _rit == _t.rend(); else return _it == _t.end();}
|
||||
inline void operator ++() {if (_inv) _rit++; else _it++; _break = false;}
|
||||
bool isEnd() {if (_inv) return _rit == _t.rend(); else return _it == _t.end();}
|
||||
void operator ++() {if (_inv) _rit++; else _it++; _break = false;}
|
||||
};
|
||||
|
||||
template <typename T> inline _PIForeach<T> _PIForeachNew(T & t, bool i = false) {return _PIForeach<T>(t, i);}
|
||||
@@ -110,27 +110,27 @@ template <typename T> inline _PIForeachC<T> * _PIForeachCastC(_PIForeachBase & c
|
||||
template<typename Enum>
|
||||
class PIFlags {
|
||||
public:
|
||||
inline PIFlags(): flags(0) {;}
|
||||
inline PIFlags(Enum e): flags(e) {;}
|
||||
inline PIFlags(const PIFlags & f): flags(f.flags) {;}
|
||||
inline PIFlags(const int i): flags(i) {;}
|
||||
inline void operator =(const PIFlags & f) {flags = f.flags;}
|
||||
inline void operator =(const Enum & e) {flags = e;}
|
||||
inline void operator =(const int & i) {flags = i;}
|
||||
inline void operator |=(const PIFlags & f) {flags = flags | f.flags;}
|
||||
inline void operator |=(const Enum & e) {flags = flags | e;}
|
||||
inline void operator |=(const int i) {flags = flags | i;}
|
||||
inline void operator &=(const PIFlags & f) {flags = flags & f.flags;}
|
||||
inline void operator &=(const Enum & e) {flags = flags & e;}
|
||||
inline void operator &=(const int i) {flags = flags & i;}
|
||||
inline PIFlags & operator |(PIFlags f) const {PIFlags tf(flags | f.flags); return tf;}
|
||||
inline PIFlags & operator |(Enum e) const {PIFlags tf(flags | e); return tf;}
|
||||
inline PIFlags & operator |(int i) const {PIFlags tf(flags | i); return tf;}
|
||||
inline PIFlags & operator &(PIFlags f) const {PIFlags tf(flags & f.flags); return tf;}
|
||||
inline PIFlags & operator &(Enum e) const {PIFlags tf(flags & e); return tf;}
|
||||
inline PIFlags & operator &(int i) const {PIFlags tf(flags & i); return tf;}
|
||||
inline bool operator [](Enum e) {return (flags & e) == e;}
|
||||
inline operator int() const {return flags;}
|
||||
PIFlags(): flags(0) {;}
|
||||
PIFlags(Enum e): flags(e) {;}
|
||||
PIFlags(const PIFlags & f): flags(f.flags) {;}
|
||||
PIFlags(const int i): flags(i) {;}
|
||||
void operator =(const PIFlags & f) {flags = f.flags;}
|
||||
void operator =(const Enum & e) {flags = e;}
|
||||
void operator =(const int & i) {flags = i;}
|
||||
void operator |=(const PIFlags & f) {flags = flags | f.flags;}
|
||||
void operator |=(const Enum & e) {flags = flags | e;}
|
||||
void operator |=(const int i) {flags = flags | i;}
|
||||
void operator &=(const PIFlags & f) {flags = flags & f.flags;}
|
||||
void operator &=(const Enum & e) {flags = flags & e;}
|
||||
void operator &=(const int i) {flags = flags & i;}
|
||||
PIFlags & operator |(PIFlags f) const {PIFlags tf(flags | f.flags); return tf;}
|
||||
PIFlags & operator |(Enum e) const {PIFlags tf(flags | e); return tf;}
|
||||
PIFlags & operator |(int i) const {PIFlags tf(flags | i); return tf;}
|
||||
PIFlags & operator &(PIFlags f) const {PIFlags tf(flags & f.flags); return tf;}
|
||||
PIFlags & operator &(Enum e) const {PIFlags tf(flags & e); return tf;}
|
||||
PIFlags & operator &(int i) const {PIFlags tf(flags & i); return tf;}
|
||||
bool operator [](Enum e) {return (flags & e) == e;}
|
||||
operator int() const {return flags;}
|
||||
private:
|
||||
int flags;
|
||||
};
|
||||
@@ -140,28 +140,28 @@ class PIVector: public vector<Type, Allocator> {
|
||||
typedef PIVector<Type, Allocator> _CVector;
|
||||
typedef vector<Type, Allocator> _stlc;
|
||||
public:
|
||||
inline PIVector() {;}
|
||||
inline PIVector(const Type & value) {_stlc::push_back(value);}
|
||||
inline PIVector(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
inline PIVector(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
inline PIVector(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
inline PIVector(uint size, const Type & value = Type()) {_stlc::resize(size, value);}
|
||||
inline const Type & at(uint index) const {return (*this)[index];}
|
||||
inline Type & at(uint index) {return (*this)[index];}
|
||||
inline const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
inline Type * data(uint index = 0) {return &(*this)[index];}
|
||||
inline int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
inline bool isEmpty() const {return _stlc::empty();}
|
||||
inline _CVector & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
inline _CVector & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
|
||||
inline _CVector & push_front(const Type & t) {_stlc::insert(_stlc::begin(), t); return *this;}
|
||||
inline _CVector & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
inline _CVector & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
inline _CVector & remove(const Type & t) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) {_stlc::erase(i); --i;} return *this;}
|
||||
inline _CVector & insert(uint pos, const Type & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
inline _CVector & operator <<(const Type & t) {_stlc::push_back(t); return *this;}
|
||||
inline _CVector & operator <<(const _CVector & t) {piForeachCA (i, t) _stlc::push_back(i); return *this;}
|
||||
inline bool contain(const Type & v) const {for (uint i = 0; i < _stlc::size(); ++i) if (v == at(i)) return true; return false;}
|
||||
PIVector() {;}
|
||||
PIVector(const Type & value) {_stlc::push_back(value);}
|
||||
PIVector(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
PIVector(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
PIVector(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
PIVector(uint size, const Type & value = Type()) {_stlc::resize(size, value);}
|
||||
const Type & at(uint index) const {return (*this)[index];}
|
||||
Type & at(uint index) {return (*this)[index];}
|
||||
const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
Type * data(uint index = 0) {return &(*this)[index];}
|
||||
int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
bool isEmpty() const {return _stlc::empty();}
|
||||
_CVector & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
_CVector & pop_front() {_stlc::erase(_stlc::begin()); return *this;}
|
||||
_CVector & push_front(const Type & t) {_stlc::insert(_stlc::begin(), t); return *this;}
|
||||
_CVector & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
_CVector & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
_CVector & remove(const Type & t) {for (typename _stlc::iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) {_stlc::erase(i); --i;} return *this;}
|
||||
_CVector & insert(uint pos, const Type & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
_CVector & operator <<(const Type & t) {_stlc::push_back(t); return *this;}
|
||||
_CVector & operator <<(const _CVector & t) {for (typename _stlc::iterator i = t.begin(); i != t.end(); i++) _stlc::push_back(*i); return *this;}
|
||||
bool contain(const Type & v) const {for (uint i = 0; i < _stlc::size(); ++i) if (v == at(i)) return true; return false;}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
@@ -172,22 +172,24 @@ class PIList: public list<Type, Allocator> {
|
||||
typedef PIList<Type, Allocator> _CList;
|
||||
typedef list<Type, Allocator> _stlc;
|
||||
public:
|
||||
inline PIList() {;}
|
||||
inline PIList(const Type & value) {_stlc::resize(1, value);}
|
||||
inline PIList(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
inline PIList(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
inline PIList(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
inline PIList(uint size, const Type & value = Type()) {_stlc::resize(size, value);}
|
||||
inline const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
inline Type * data(uint index = 0) {return &(*this)[index];}
|
||||
inline int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
inline bool isEmpty() const {return _stlc::empty();}
|
||||
inline _CList & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
inline _CList & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
inline _CList & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
inline _CList & insert(uint pos, const Type & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
inline _CList & operator <<(const Type & t) {_stlc::push_back(t); return *this;}
|
||||
inline PIVector<Type, Allocator> toVector() {PIVector<Type, Allocator> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
|
||||
PIList() {;}
|
||||
PIList(const Type & value) {_stlc::resize(1, value);}
|
||||
PIList(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
PIList(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
PIList(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
PIList(uint size, const Type & value = Type()) {_stlc::resize(size, value);}
|
||||
Type & operator [](uint index) {return (*this)[index];}
|
||||
Type & operator [](uint index) const {return (*this)[index];}
|
||||
const Type * data(uint index = 0) const {return &(*this)[index];}
|
||||
Type * data(uint index = 0) {return &(*this)[index];}
|
||||
int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
bool isEmpty() const {return _stlc::empty();}
|
||||
_CList & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
|
||||
_CList & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
_CList & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
_CList & insert(uint pos, const Type & t) {_stlc::insert(_stlc::begin() + pos, t); return *this;}
|
||||
_CList & operator <<(const Type & t) {_stlc::push_back(t); return *this;}
|
||||
PIVector<Type, Allocator> toVector() {PIVector<Type, Allocator> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
|
||||
};
|
||||
|
||||
template<typename Type, typename Compare = std::less<Type>, typename Allocator = std::allocator<Type> >
|
||||
@@ -195,34 +197,34 @@ class PISet: public set<Type, Compare, Allocator> {
|
||||
typedef PISet<Type, Compare, Allocator> _CSet;
|
||||
typedef set<Type, Compare, Allocator> _stlc;
|
||||
public:
|
||||
inline PISet() {;}
|
||||
inline PISet(const Type & value) {_stlc::resize(1, value);}
|
||||
inline PISet(const Type & v0, const Type & v1) {_stlc::insert(v0); _stlc::insert(v1);}
|
||||
inline PISet(const Type & v0, const Type & v1, const Type & v2) {_stlc::insert(v0); _stlc::insert(v1); _stlc::insert(v2);}
|
||||
inline PISet(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::insert(v0); _stlc::insert(v1); _stlc::insert(v2); _stlc::insert(v3);}
|
||||
inline int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
inline bool isEmpty() const {return _stlc::empty();}
|
||||
inline _CSet & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
inline _CSet & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
inline _CSet & operator <<(const Type & t) {_stlc::insert(t); return *this;}
|
||||
inline bool operator [](const Type & t) {return _stlc::find(t);}
|
||||
inline PIVector<Type, Allocator> toVector() {PIVector<Type, Allocator> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
|
||||
PISet() {;}
|
||||
PISet(const Type & value) {_stlc::resize(1, value);}
|
||||
PISet(const Type & v0, const Type & v1) {_stlc::insert(v0); _stlc::insert(v1);}
|
||||
PISet(const Type & v0, const Type & v1, const Type & v2) {_stlc::insert(v0); _stlc::insert(v1); _stlc::insert(v2);}
|
||||
PISet(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::insert(v0); _stlc::insert(v1); _stlc::insert(v2); _stlc::insert(v3);}
|
||||
int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
bool isEmpty() const {return _stlc::empty();}
|
||||
_CSet & remove(uint num) {_stlc::erase(_stlc::begin() + num); return *this;}
|
||||
_CSet & remove(uint num, uint count) {_stlc::erase(_stlc::begin() + num, _stlc::begin() + num + count); return *this;}
|
||||
_CSet & operator <<(const Type & t) {_stlc::insert(t); return *this;}
|
||||
bool operator [](const Type & t) {return _stlc::find(t);}
|
||||
PIVector<Type, Allocator> toVector() {PIVector<Type, Allocator> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class PIStack: public PIVector<Type> {
|
||||
typedef PIStack<Type> _CStack;
|
||||
public:
|
||||
inline PIStack() {;}
|
||||
inline PIStack(const Type & value) {_CStack::resize(1, value);}
|
||||
inline PIStack(const Type & v0, const Type & v1) {_CStack::push_back(v0); _CStack::push_back(v1);}
|
||||
inline PIStack(const Type & v0, const Type & v1, const Type & v2) {_CStack::push_back(v0); _CStack::push_back(v1); _CStack::push_back(v2);}
|
||||
inline PIStack(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_CStack::push_back(v0); _CStack::push_back(v1); _CStack::push_back(v2); _CStack::push_back(v3);}
|
||||
inline _CStack & push(const Type & v) {_CStack::push_back(v); return *this;}
|
||||
inline Type pop() {Type t = Type(); if (_CStack::size() == 0) return t; t = _CStack::back(); _CStack::pop_back(); return t;}
|
||||
inline Type & top() {return _CStack::back();}
|
||||
inline const Type & top() const {return _CStack::back();}
|
||||
inline PIVector<Type> toVector() {PIVector<Type> v; for (typename _CStack::const_iterator i = _CStack::begin(); i != _CStack::end(); ++i) v << *i; return v;}
|
||||
PIStack() {;}
|
||||
PIStack(const Type & value) {_CStack::resize(1, value);}
|
||||
PIStack(const Type & v0, const Type & v1) {_CStack::push_back(v0); _CStack::push_back(v1);}
|
||||
PIStack(const Type & v0, const Type & v1, const Type & v2) {_CStack::push_back(v0); _CStack::push_back(v1); _CStack::push_back(v2);}
|
||||
PIStack(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_CStack::push_back(v0); _CStack::push_back(v1); _CStack::push_back(v2); _CStack::push_back(v3);}
|
||||
_CStack & push(const Type & v) {_CStack::push_back(v); return *this;}
|
||||
Type pop() {Type t = Type(); if (_CStack::size() == 0) return t; t = _CStack::back(); _CStack::pop_back(); return t;}
|
||||
Type & top() {return _CStack::back();}
|
||||
const Type & top() const {return _CStack::back();}
|
||||
PIVector<Type> toVector() {PIVector<Type> v; for (typename _CStack::const_iterator i = _CStack::begin(); i != _CStack::end(); ++i) v << *i; return v;}
|
||||
};
|
||||
|
||||
template<typename Type, typename Allocator = std::allocator<Type> >
|
||||
@@ -230,39 +232,39 @@ class PIDeque: public deque<Type, Allocator> {
|
||||
typedef PIDeque<Type, Allocator> _CDeque;
|
||||
typedef deque<Type, Allocator> _stlc;
|
||||
public:
|
||||
inline PIDeque() {;}
|
||||
inline PIDeque(const Type & value) {_stlc::resize(1, value);}
|
||||
inline PIDeque(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
inline PIDeque(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
inline PIDeque(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
inline int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
inline bool isEmpty() const {return _stlc::empty();}
|
||||
inline _CDeque & operator <<(const Type & t) {_CDeque::push_back(t); return *this;}
|
||||
inline PIVector<Type, Allocator> toVector() {PIVector<Type, Allocator> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
|
||||
PIDeque() {;}
|
||||
PIDeque(const Type & value) {_stlc::resize(1, value);}
|
||||
PIDeque(const Type & v0, const Type & v1) {_stlc::push_back(v0); _stlc::push_back(v1);}
|
||||
PIDeque(const Type & v0, const Type & v1, const Type & v2) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2);}
|
||||
PIDeque(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
|
||||
int size_s() const {return static_cast<int>(_stlc::size());}
|
||||
bool isEmpty() const {return _stlc::empty();}
|
||||
_CDeque & operator <<(const Type & t) {_CDeque::push_back(t); return *this;}
|
||||
PIVector<Type, Allocator> toVector() {PIVector<Type, Allocator> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
class PIQueue: public PIDeque<Type> {
|
||||
typedef PIQueue<Type> _CQueue;
|
||||
public:
|
||||
inline PIQueue() {;}
|
||||
inline PIQueue(const Type & value) {_CQueue::resize(1, value);}
|
||||
inline PIQueue(const Type & v0, const Type & v1) {_CQueue::push_front(v0); _CQueue::push_front(v1);}
|
||||
inline PIQueue(const Type & v0, const Type & v1, const Type & v2) {_CQueue::push_front(v0); _CQueue::push_front(v1); _CQueue::push_front(v2);}
|
||||
inline PIQueue(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_CQueue::push_front(v0); _CQueue::push_front(v1); _CQueue::push_front(v2); _CQueue::push_front(v3);}
|
||||
inline _CQueue & enqueue(const Type & v) {_CQueue::push_front(v); return *this;}
|
||||
inline Type dequeue() {Type t = Type(); if (_CQueue::size() == 0) return t; t = _CQueue::back(); _CQueue::pop_back(); return t;}
|
||||
inline Type & head() {return _CQueue::back();}
|
||||
inline const Type & head() const {return _CQueue::back();}
|
||||
inline PIVector<Type> toVector() {PIVector<Type> v; for (typename _CQueue::const_iterator i = _CQueue::begin(); i != _CQueue::end(); ++i) v << *i; return v;}
|
||||
PIQueue() {;}
|
||||
PIQueue(const Type & value) {_CQueue::resize(1, value);}
|
||||
PIQueue(const Type & v0, const Type & v1) {_CQueue::push_front(v0); _CQueue::push_front(v1);}
|
||||
PIQueue(const Type & v0, const Type & v1, const Type & v2) {_CQueue::push_front(v0); _CQueue::push_front(v1); _CQueue::push_front(v2);}
|
||||
PIQueue(const Type & v0, const Type & v1, const Type & v2, const Type & v3) {_CQueue::push_front(v0); _CQueue::push_front(v1); _CQueue::push_front(v2); _CQueue::push_front(v3);}
|
||||
_CQueue & enqueue(const Type & v) {_CQueue::push_front(v); return *this;}
|
||||
Type dequeue() {Type t = Type(); if (_CQueue::size() == 0) return t; t = _CQueue::back(); _CQueue::pop_back(); return t;}
|
||||
Type & head() {return _CQueue::back();}
|
||||
const Type & head() const {return _CQueue::back();}
|
||||
PIVector<Type> toVector() {PIVector<Type> v; for (typename _CQueue::const_iterator i = _CQueue::begin(); i != _CQueue::end(); ++i) v << *i; return v;}
|
||||
};
|
||||
|
||||
|
||||
template<typename Type0, typename Type1>
|
||||
class PIPair {
|
||||
public:
|
||||
inline PIPair() {first = Type0(); second = Type1();}
|
||||
inline PIPair(const Type0 & value0, const Type1 & value1) {first = value0; second = value1;}
|
||||
PIPair() {first = Type0(); second = Type1();}
|
||||
PIPair(const Type0 & value0, const Type1 & value1) {first = value0; second = value1;}
|
||||
Type0 first;
|
||||
Type1 second;
|
||||
};
|
||||
@@ -275,11 +277,11 @@ class PIHash: public PISet<PIPair<Key, Type> > {
|
||||
typedef PIHash<Type, Key> _CHash;
|
||||
typedef PISet<PIPair<Key, Type> > _CSet;
|
||||
public:
|
||||
inline PIHash() {;}
|
||||
inline PIHash(const Type & value, const Key & key) {insert(value, key);}
|
||||
inline _CHash & insert(const Type & value, const Key & key) {_CSet::insert(PIPair<Key, Type>(key, value));}
|
||||
inline Type value(Key key) {piForeachCA (i, *this) if (i.first == key) return i.second;; return Key();}
|
||||
inline Type operator[](Key key) {return value(key);}
|
||||
PIHash() {;}
|
||||
PIHash(const Type & value, const Key & key) {insert(value, key);}
|
||||
_CHash & insert(const Type & value, const Key & key) {_CSet::insert(PIPair<Key, Type>(key, value));}
|
||||
Type value(Key key) {for (typename _CHash::iterator i = _CHash::begin(); i != _CHash::end(); i++) if ((*i).first == key) return (*i).second; return Key();}
|
||||
Type operator[](Key key) {return value(key);}
|
||||
};
|
||||
|
||||
#endif // PICONTAINERS_H
|
||||
|
||||
Reference in New Issue
Block a user