git-svn-id: svn://db.shs.com.ru/pip@367 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-04-14 17:37:58 +00:00
parent 1a041d5f2b
commit 9058bdc521
38 changed files with 190 additions and 221 deletions

View File

@@ -27,7 +27,6 @@
#define PICONTAINERS_H
#include "picout.h"
#include <list>
#include <malloc.h>
#ifndef PIP_MEMALIGN_BYTES
@@ -48,31 +47,6 @@
# define afree(p) free(p)
#endif
template<typename Type0, typename Type1>
class PIP_EXPORT PIPair {
public:
PIPair() {first = Type0(); second = Type1();}
PIPair(const Type0 & value0, const Type1 & value1) {first = value0; second = value1;}
Type0 first;
Type1 second;
};
template<typename Type0, typename Type1>
inline bool operator <(const PIPair<Type0, Type1> & value0, const PIPair<Type0, Type1> & value1) {return value0.first < value1.first;}
template<typename Type0, typename Type1>
inline bool operator ==(const PIPair<Type0, Type1> & value0, const PIPair<Type0, Type1> & value1) {return (value0.first == value1.first) && (value0.second == value1.second);}
template<typename Type0, typename Type1>
inline bool operator !=(const PIPair<Type0, Type1> & value0, const PIPair<Type0, Type1> & value1) {return (value0.first != value1.first) || (value0.second != value1.second);}
template<typename Type0, typename Type1>
inline std::ostream & operator <<(std::ostream & s, const PIPair<Type0, Type1> & v) {s << "(" << v.first << ", " << v.second << ")"; return s;}
template<typename Type0, typename Type1>
inline PICout operator <<(PICout s, const PIPair<Type0, Type1> & v) {s.space(); s.setControl(0, true); s << "(" << v.first << ", " << v.second << ")"; s.restoreControl(); return s;}
#include "pivector.h"
#include "pistack.h"
#include "piqueue.h"
#include "pideque.h"
#include "pimap.h"
#include "piset.h"
#ifdef DOXYGEN
@@ -246,57 +220,5 @@ template <typename T> inline _PIForeachC<T> * _PIForeachCastC(_PIForeachBase & c
#endif // DOXYGEN
template<typename Type, typename Allocator = std::allocator<Type> >
class PIP_EXPORT PIList: public std::list<Type, Allocator> {
typedef PIList<Type, Allocator> _CList;
typedef std::list<Type, Allocator> _stlc;
public:
PIList() {piMonitor.containers++;}
PIList(const Type & value) {piMonitor.containers++; _stlc::resize(1, value);}
PIList(const Type & v0, const Type & v1) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1);}
PIList(const Type & v0, const Type & v1, const Type & v2) {piMonitor.containers++; _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) {piMonitor.containers++; _stlc::push_back(v0); _stlc::push_back(v1); _stlc::push_back(v2); _stlc::push_back(v3);}
PIList(uint size, const Type & value = Type()) {piMonitor.containers++; _stlc::resize(size, value);}
~PIList() {piMonitor.containers--;}
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();}
bool has(const Type & t) const {for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) return true; return false;}
int etries(const Type & t) const {int ec = 0; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) if (t == *i) ++ec; return ec;}
_CList & fill(const Type & t) {_stlc::assign(_stlc::size(), t); return *this;}
_CList & remove(uint index) {_stlc::erase(_stlc::begin() + index); return *this;}
_CList & remove(uint index, uint count) {_stlc::erase(_stlc::begin() + index, _stlc::begin() + index + 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> toVector() const {PIVector<Type> v; for (typename _stlc::const_iterator i = _stlc::begin(); i != _stlc::end(); ++i) v << *i; return v;}
};
#ifndef PIP_CONTAINERS_STL
# define __PICONTAINERS_SIMPLE_TYPE__(T) \
__PIDEQUE_SIMPLE_TYPE__(T)\
__PIVECTOR_SIMPLE_TYPE__(T)
__PICONTAINERS_SIMPLE_TYPE__(bool)
__PICONTAINERS_SIMPLE_TYPE__(char)
__PICONTAINERS_SIMPLE_TYPE__(uchar)
__PICONTAINERS_SIMPLE_TYPE__(short)
__PICONTAINERS_SIMPLE_TYPE__(ushort)
__PICONTAINERS_SIMPLE_TYPE__(int)
__PICONTAINERS_SIMPLE_TYPE__(uint)
__PICONTAINERS_SIMPLE_TYPE__(long)
__PICONTAINERS_SIMPLE_TYPE__(ulong)
__PICONTAINERS_SIMPLE_TYPE__(llong)
__PICONTAINERS_SIMPLE_TYPE__(ullong)
__PICONTAINERS_SIMPLE_TYPE__(float)
__PICONTAINERS_SIMPLE_TYPE__(double)
__PICONTAINERS_SIMPLE_TYPE__(ldouble)
#endif
#endif // PICONTAINERS_H