15.04.2014 - Version 0.3.8_beta, last version of 0.3.8 branch. Too much added and fixed...

This commit is contained in:
peri4
2014-04-15 13:19:07 +04:00
parent f50891b376
commit 77abb0bbea
46 changed files with 4538 additions and 2515 deletions

View File

@@ -1,7 +1,7 @@
/*! \file picontainers.h
/*! \file pivector.h
* \brief Dynamic array of any type
*
* This file declare PIVector
* This file declares PIVector
*/
/*
PIP - Platform Independent Primitives
@@ -34,26 +34,27 @@
template <typename T>
class PIVector {
public:
PIVector(): __piv_data__(0), __piv_size__(0), __piv_rsize__(0) {
PIVector(): piv_data(0), piv_size(0), piv_rsize(0) {
//printf("new vector 1 %p (%s) ... !{\n", this, typeid(T).name());
//printf("(s=%d, d=%p) }!\n", int(__piv_size__), __piv_data__);
//printf("(s=%d, d=%p) }!\n", int(piv_size), piv_data);
}
PIVector(const PIVector<T> & other): __piv_data__(0), __piv_size__(0), __piv_rsize__(0) {
PIVector(const PIVector<T> & other): piv_data(0), piv_size(0), piv_rsize(0) {
//printf("new vector 2 %p (%s) ... !{\n", this, typeid(T).name());
alloc(other.__piv_size__);
for (ullong i = 0; i < __piv_size__; ++i)
new(__piv_data__ + i)T(other.__piv_data__[i]);
//printf("(s=%d, d=%p) }!\n", int(__piv_size__), __piv_data__);
alloc(other.piv_size);
for (size_t i = 0; i < piv_size; ++i)
new(piv_data + i)T(other.piv_data[i]);
//printf("(s=%d, d=%p) }!\n", int(piv_size), piv_data);
}
PIVector(ullong __piv_size__, const T & f = T()): __piv_data__(0), __piv_size__(0), __piv_rsize__(0) {
PIVector(size_t piv_size, const T & f = T()): piv_data(0), piv_size(0), piv_rsize(0) {
//printf("new vector 3 %p (%s) ... !{\n", this, typeid(T).name());
resize(__piv_size__, f);
//printf("(s=%d, d=%p) }!\n", int(__piv_size__), __piv_data__);
resize(piv_size, f);
//printf("(s=%d, d=%p) }!\n", int(piv_size), piv_data);
}
~PIVector() {
//printf("delete vector %p (%s) (s=%d, d=%p) ... ~{\n", this, typeid(T).name(), int(__piv_size__), __piv_data__);
deleteT(__piv_data__, __piv_size__);
//printf("delete vector %p (%s) (s=%d, d=%p) ... ~{\n", this, typeid(T).name(), int(piv_size), piv_data);
deleteT(piv_data, piv_size);
dealloc();
//deleteRaw(piv_tdata);
_reset();
//printf("}~\n");
}
@@ -61,25 +62,25 @@ public:
PIVector<T> & operator =(const PIVector<T> & other) {
if (this == &other) return *this;
bool tj, oj;
tj = (__piv_size__ != 0 && __piv_data__ == 0);// || (__piv_size__ == 0 && __piv_data__ != 0);
oj = (other.__piv_size__ != 0 && other.__piv_data__ == 0);// || (other.__piv_size__ == 0 && other.__piv_data__ != 0);
//printf("operator= (%p = %p) (s=%d, d=%p, o.s=%d, o.d=%p) (%d, %d) ... o[\n", this, &other, int(__piv_size__), __piv_data__, int(other.__piv_size__), other.__piv_data__, int(tj), int(oj));
tj = (piv_size != 0 && piv_data == 0);// || (piv_size == 0 && piv_data != 0);
oj = (other.piv_size != 0 && other.piv_data == 0);// || (other.piv_size == 0 && other.piv_data != 0);
//printf("operator= (%p = %p) (s=%d, d=%p, o.s=%d, o.d=%p) (%d, %d) ... o[\n", this, &other, int(piv_size), piv_data, int(other.piv_size), other.piv_data, int(tj), int(oj));
if (tj) {
printf("JUNK this\n");
_reset();
} else {
clear();
}
/*if (__piv_size__ == other.__piv_size__) {
for (ullong i = 0; i < __piv_size__; ++i)
__piv_data__[i] = other.__piv_data__[i];
/*if (piv_size == other.piv_size) {
for (size_t i = 0; i < piv_size; ++i)
piv_data[i] = other.piv_data[i];
return *this;
}*/
if (!oj) {
alloc(other.__piv_size__);
//zeroRaw(__piv_data__, __piv_size__);
for (ullong i = 0; i < __piv_size__; ++i)
new(__piv_data__ + i)T(other.__piv_data__[i]); //__piv_data__[i] = other.__piv_data__[i];
alloc(other.piv_size);
//zeroRaw(piv_data, piv_size);
for (size_t i = 0; i < piv_size; ++i)
new(piv_data + i)T(other.piv_data[i]); //piv_data[i] = other.piv_data[i];
} else {
printf("JUNK other\n");
}
@@ -92,9 +93,9 @@ public:
class iterator {
friend class PIVector<T>;
private:
iterator(PIVector<T> * v, ullong p): parent(v), pos(p) {}
iterator(PIVector<T> * v, size_t p): parent(v), pos(p) {}
PIVector<T> * parent;
ullong pos;
size_t pos;
public:
iterator(): parent(0) {}
T & operator *() {return (*parent)[pos];}
@@ -110,9 +111,9 @@ public:
class const_iterator {
friend class PIVector<T>;
private:
const_iterator(const PIVector<T> * v, ullong p): parent(v), pos(p) {}
const_iterator(const PIVector<T> * v, size_t p): parent(v), pos(p) {}
const PIVector<T> * parent;
ullong pos;
size_t pos;
public:
const_iterator(): parent(0) {}
//T & operator *() {return (*parent)[pos];}
@@ -128,9 +129,9 @@ public:
class reverse_iterator {
friend class PIVector<T>;
private:
reverse_iterator(PIVector<T> * v, ullong p): parent(v), pos(p) {}
reverse_iterator(PIVector<T> * v, size_t p): parent(v), pos(p) {}
PIVector<T> * parent;
ullong pos;
size_t pos;
public:
reverse_iterator(): parent(0) {}
T & operator *() {return (*parent)[pos];}
@@ -146,9 +147,9 @@ public:
class const_reverse_iterator {
friend class PIVector<T>;
private:
const_reverse_iterator(const PIVector<T> * v, ullong p): parent(v), pos(p) {}
const_reverse_iterator(const PIVector<T> * v, size_t p): parent(v), pos(p) {}
const PIVector<T> * parent;
ullong pos;
size_t pos;
public:
const_reverse_iterator(): parent(0) {}
//T & operator *() {return (*parent)[pos];}
@@ -162,129 +163,125 @@ public:
};
iterator begin() {return iterator(this, 0);}
iterator end() {return iterator(this, __piv_size__);}
iterator end() {return iterator(this, piv_size);}
const_iterator begin() const {return const_iterator(this, 0);}
const_iterator end() const {return const_iterator(this, __piv_size__);}
reverse_iterator rbegin() {return reverse_iterator(this, __piv_size__ - 1);}
const_iterator end() const {return const_iterator(this, piv_size);}
reverse_iterator rbegin() {return reverse_iterator(this, piv_size - 1);}
reverse_iterator rend() {return reverse_iterator(this, -1);}
const_reverse_iterator rbegin() const {return const_reverse_iterator(this, __piv_size__ - 1);}
const_reverse_iterator rbegin() const {return const_reverse_iterator(this, piv_size - 1);}
const_reverse_iterator rend() const {return const_reverse_iterator(this, -1);}
ullong size() const {return __piv_size__;}
int size_s() const {return __piv_size__;}
ullong length() const {return __piv_size__;}
bool isEmpty() const {return (__piv_size__ == 0);}
size_t size() const {return piv_size;}
ssize_t size_s() const {return piv_size;}
size_t length() const {return piv_size;}
bool isEmpty() const {return (piv_size == 0);}
T & operator [](ullong index) {return __piv_data__[index];}
T & at(ullong index) {return __piv_data__[index];}
const T & operator [](ullong index) const {return __piv_data__[index];}
const T & at(ullong index) const {return __piv_data__[index];}
T & back() {return __piv_data__[__piv_size__ - 1];}
const T & back() const {return __piv_data__[__piv_size__ - 1];}
T & front() {return __piv_data__[0];}
const T & front() const {return __piv_data__[0];}
bool operator ==(const PIVector<T> & t) const {if (__piv_size__ != t.__piv_size__) return false; for (ullong i = 0; i < __piv_size__; ++i) if (t[i] != __piv_data__[i]) return false; return true;}
bool operator !=(const PIVector<T> & t) const {if (__piv_size__ != t.__piv_size__) return true; for (ullong i = 0; i < __piv_size__; ++i) if (t[i] != __piv_data__[i]) return true; return false;}
bool contains(const T & v) const {for (ullong i = 0; i < __piv_size__; ++i) if (v == __piv_data__[i]) return true; return false;}
int etries(const T & v) const {int ec = 0; for (ullong i = 0; i < __piv_size__; ++i) if (v == __piv_data__[i]) ++ec; return ec;}
T & operator [](size_t index) {return piv_data[index];}
T & at(size_t index) {return piv_data[index];}
const T & operator [](size_t index) const {return piv_data[index];}
const T & at(size_t index) const {return piv_data[index];}
T & back() {return piv_data[piv_size - 1];}
const T & back() const {return piv_data[piv_size - 1];}
T & front() {return piv_data[0];}
const T & front() const {return piv_data[0];}
bool operator ==(const PIVector<T> & t) const {if (piv_size != t.piv_size) return false; for (size_t i = 0; i < piv_size; ++i) if (t[i] != piv_data[i]) return false; return true;}
bool operator !=(const PIVector<T> & t) const {if (piv_size != t.piv_size) return true; for (size_t i = 0; i < piv_size; ++i) if (t[i] != piv_data[i]) return true; return false;}
bool contains(const T & v) const {for (size_t i = 0; i < piv_size; ++i) if (v == piv_data[i]) return true; return false;}
int etries(const T & v) const {int ec = 0; for (size_t i = 0; i < piv_size; ++i) if (v == piv_data[i]) ++ec; return ec;}
T * data(ullong index = 0) {return &(__piv_data__[index]);}
const T * data(ullong index = 0) const {return &(__piv_data__[index]);}
T * data(size_t index = 0) {return &(piv_data[index]);}
const T * data(size_t index = 0) const {return &(piv_data[index]);}
PIVector<T> & clear() {resize(0); return *this;}
PIVector<T> & fill(const T & f = T()) {
//if (sizeof(T) == 1) memset(__piv_data__, f, __piv_size__);
deleteT(__piv_data__, __piv_size__);
//zeroRaw(__piv_data__, __piv_size__);
for (ullong i = 0; i < __piv_size__; ++i)
new(__piv_data__ + i)T(f);
//if (sizeof(T) == 1) memset(piv_data, f, piv_size);
deleteT(piv_data, piv_size);
//zeroRaw(piv_data, piv_size);
for (size_t i = 0; i < piv_size; ++i)
new(piv_data + i)T(f);
return *this;
}
PIVector<T> & assign(const T & f = T()) {return fill(f);}
PIVector<T> & resize(ullong new_size, const T & f = T()) {
if (new_size < __piv_size__) {
T * de = &(__piv_data__[new_size]);
deleteT(de, __piv_size__ - new_size);
__piv_size__ = new_size;
PIVector<T> & assign(size_t new_size, const T & f) {resize(new_size); fill(f);}
PIVector<T> & resize(size_t new_size, const T & f = T()) {
if (new_size < piv_size) {
T * de = &(piv_data[new_size]);
deleteT(de, piv_size - new_size);
piv_size = new_size;
}
if (new_size > __piv_size__) {
ullong os = __piv_size__;
if (new_size > piv_size) {
size_t os = piv_size;
alloc(new_size);
//if (sizeof(T) == 1) memset(&(__piv_data__[os]), f, ds);
//zeroRaw(&(__piv_data__[os]), new_size - os);
for (ullong i = os; i < new_size; ++i) new(__piv_data__ + i)T(f);
//if (sizeof(T) == 1) memset(&(piv_data[os]), f, ds);
//zeroRaw(&(piv_data[os]), new_size - os);
for (size_t i = os; i < new_size; ++i) new(piv_data + i)T(f);
}
return *this;
}
PIVector<T> & reserve(ullong new_size) {if (new_size <= __piv_rsize__) return *this; ullong os = __piv_size__; alloc(new_size); __piv_size__ = os; return *this;}
PIVector<T> & reserve(size_t new_size) {if (new_size <= piv_rsize) return *this; size_t os = piv_size; alloc(new_size); piv_size = os; return *this;}
PIVector<T> & insert(ullong index, const T & v = T()) {
alloc(__piv_size__ + 1);
if (index < __piv_size__ - 1) {
ullong os = __piv_size__ - index - 1;
T * pd = newRaw(os);
memcpy(pd, &(__piv_data__[index]), os * sizeof(T));
memcpy(&(__piv_data__[index + 1]), pd, os * sizeof(T));
deleteRaw(pd);
PIVector<T> & insert(size_t index, const T & v = T()) {
alloc(piv_size + 1);
if (index < piv_size - 1) {
size_t os = piv_size - index - 1;
memmove(&(piv_data[index + 1]), &(piv_data[index]), os * sizeof(T));
}
//zeroRaw(&(__piv_data__[index]), 1);
new(__piv_data__ + index)T(v);
//zeroRaw(&(piv_data[index]), 1);
new(piv_data + index)T(v);
return *this;
}
PIVector<T> & remove(ullong index, ullong count = 1) {
if (index + count >= __piv_size__) {
PIVector<T> & remove(size_t index, size_t count = 1) {
if (index + count >= piv_size) {
resize(index);
return *this;
}
ullong os = __piv_size__ - index - count;
T * pd = newRaw(os), * de = &(__piv_data__[index]);
size_t os = piv_size - index - count;
T * de = &(piv_data[index]);
deleteT(de, count);
memcpy(pd, &(__piv_data__[index + count]), os * sizeof(T));
memcpy(&(__piv_data__[index]), pd, os * sizeof(T));
deleteRaw(pd);
__piv_size__ -= count;
memmove(&(piv_data[index]), &(piv_data[index + count]), os * sizeof(T));
piv_size -= count;
return *this;
}
void swap(PIVector<T> & other) {
piSwap<T*>(__piv_data__, other.__piv_data__);
piSwap<ullong>(__piv_size__, other.__piv_size__);
piSwap<ullong>(__piv_rsize__, other.__piv_rsize__);
piSwap<T*>(piv_data, other.piv_data);
piSwap<size_t>(piv_size, other.piv_size);
piSwap<size_t>(piv_rsize, other.piv_rsize);
}
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);}
PIVector<T> & sort(CompareFunc compare = compare_func) {qsort(__piv_data__, __piv_size__, sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
static int compare_func(const T * t0, const T * t1) {return (*t0) < (*t1) ? -1 : ((*t0) == (*t1) ? 0 : 1);}
PIVector<T> & sort(CompareFunc compare = compare_func) {qsort(piv_data, piv_size, sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
PIVector<T> & enlarge(llong __piv_size__) {llong ns = size_s() + __piv_size__; if (ns <= 0) clear(); else resize(ullong(ns)); return *this;}
PIVector<T> & enlarge(llong piv_size) {llong ns = size_s() + piv_size; if (ns <= 0) clear(); else resize(size_t(ns)); return *this;}
PIVector<T> & removeOne(const T & v) {for (ullong i = 0; i < __piv_size__; ++i) if (__piv_data__[i] == v) {remove(i); return *this;} return *this;}
PIVector<T> & removeAll(const T & v) {for (ullong i = 0; i < __piv_size__; ++i) if (__piv_data__[i] == v) {remove(i); --i;} return *this;}
PIVector<T> & removeOne(const T & v) {for (size_t i = 0; i < piv_size; ++i) if (piv_data[i] == v) {remove(i); return *this;} return *this;}
PIVector<T> & removeAll(const T & v) {for (llong i = 0; i < piv_size; ++i) if (piv_data[i] == v) {remove(i); --i;} return *this;}
PIVector<T> & push_back(const T & v) {alloc(__piv_size__ + 1); new(__piv_data__ + __piv_size__ - 1)T(v); return *this;}
PIVector<T> & push_back(const T & v) {alloc(piv_size + 1); new(piv_data + piv_size - 1)T(v); return *this;}
PIVector<T> & append(const T & v) {return push_back(v);}
PIVector<T> & operator <<(const T & v) {return push_back(v);}
PIVector<T> & push_front(const T & v) {insert(0, v); return *this;}
PIVector<T> & prepend(const T & v) {return push_front(v);}
PIVector<T> & pop_back() {if (__piv_size__ == 0) return *this; resize(__piv_size__ - 1); return *this;}
PIVector<T> & pop_front() {if (__piv_size__ == 0) return *this; remove(0); return *this;}
PIVector<T> & pop_back() {if (piv_size == 0) return *this; resize(piv_size - 1); return *this;}
PIVector<T> & pop_front() {if (piv_size == 0) return *this; remove(0); return *this;}
T take_back() {T t(back()); pop_back(); return t;}
T take_front() {T t(front()); pop_front(); return t;}
private:
void _reset() {__piv_size__ = __piv_rsize__ = 0; __piv_data__ = 0;}
ullong asize(ullong s) {
void _reset() {piv_size = piv_rsize = 0; piv_data = 0;}
size_t asize(size_t s) {
if (s == 0) return 0;
if (__piv_rsize__ + __piv_rsize__ >= s && __piv_rsize__ < s)
return __piv_rsize__ + __piv_rsize__;
ullong t = 0, s_ = s - 1;
if (piv_rsize + piv_rsize >= s && piv_rsize < s)
return piv_rsize + piv_rsize;
size_t t = 0, s_ = s - 1;
while (s_ >> t) ++t;
return (1 << t);
}
T * newRaw(ullong s) {
T * newRaw(size_t s) {
//cout << std::dec << " ![("<<this<<")newRaw " << s << " elements ... <\n" << endl;
//uchar * ret = new uchar[s * sizeof(T)];
uchar * ret = (uchar*)(malloc(s * sizeof(T)));//new uchar[];
@@ -292,55 +289,110 @@ private:
//cout << std::hex << " > (new 0x" << (llong)ret << ") ok]!" << endl;
return (T*)ret;
}
void deleteT(T * d, ullong sz) {
/*void reallocRawTemp(size_t s) {
if (piv_tdata == 0) piv_tdata = (T*)(malloc(s * sizeof(T)));
else piv_tdata = (T*)(realloc(piv_tdata, s * sizeof(T)));
}*/
void deleteT(T * d, size_t sz) {
//cout << " ~[("<<this<<")deleteT " << std::dec << sz << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
if ((uchar*)d != 0) {
for (ullong i = 0; i < sz; ++i)
for (size_t i = 0; i < sz; ++i)
d[i].~T();
//zeroRaw(d, sz);
}
//cout << " > ok]~" << endl;
}
void deleteRaw(T *& d) {
//cout << " ~[("<<this<<")deleteRaw " << std::dec << __piv_rsize__ << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
//cout << " ~[("<<this<<")deleteRaw " << std::dec << piv_rsize << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
if ((uchar*)d != 0) free((uchar*)d);
d = 0;
//cout << " > ok]~" << endl;
}
void zeroRaw(T * d, ullong s) {
void zeroRaw(T * d, size_t s) {
//cout << " ~[("<<this<<")zeroRaw " << std::dec << s << " elements " << std::hex << "0x" << (llong)d << " ... <\n" << endl;
if ((uchar*)d != 0) memset(d, 0, s*sizeof(T));
//cout << " > ok]~" << endl;
}
void dealloc() {deleteRaw(__piv_data__);}
void alloc(ullong new_size) {
if (new_size <= __piv_rsize__) {
__piv_size__ = new_size;
void dealloc() {deleteRaw(piv_data);}
inline void alloc(size_t new_size) {
if (new_size <= piv_rsize) {
piv_size = new_size;
return;
}
//int os = __piv_size__;
__piv_size__ = new_size;
ullong as = asize(new_size);
if (as == __piv_rsize__) return;
//int os = piv_size;
piv_size = new_size;
size_t as = asize(new_size);
if (as == piv_rsize) return;
//cout << std::hex << " ![("<<this<<")realloc " << __piv_data__ << " data ... <\n" << endl;
__piv_data__ = (T*)(realloc(__piv_data__, as*sizeof(T)));
//zeroRaw(&(__piv_data__[os]), as - os);
__piv_rsize__ = as;
//cout << std::hex << " > (new 0x" << (llong)__piv_data__ << ") ok]!" << endl;
/*__piv_rsize__ = as;
T * pd = newRaw(__piv_rsize__);
if (os > 0 && __piv_data__ != 0) {
memcpy(pd, __piv_data__, os * sizeof(T));
deleteRaw(__piv_data__);
//cout << std::hex << " ![("<<this<<")realloc " << piv_data << " data ... <\n" << endl;
piv_data = (T*)(realloc(piv_data, as*sizeof(T)));
//zeroRaw(&(piv_data[os]), as - os);
piv_rsize = as;
//cout << std::hex << " > (new 0x" << (llong)piv_data << ") ok]!" << endl;
/*piv_rsize = as;
T * pd = newRaw(piv_rsize);
if (os > 0 && piv_data != 0) {
memcpy(pd, piv_data, os * sizeof(T));
deleteRaw(piv_data);
}
__piv_data__ = pd;*/
piv_data = pd;*/
}
T * __piv_data__;
ullong __piv_size__, __piv_rsize__;
T * piv_data;
size_t piv_size, piv_rsize;
};
#define __PIVECTOR_SIMPLE_FUNCTIONS__(T) \
template<> inline PIVector<T>::~PIVector() {dealloc(); _reset();} \
template<> inline PIVector<T> & PIVector<T>::push_back(const T & v) {alloc(piv_size + 1); piv_data[piv_size - 1] = v; return *this;} \
template<> inline PIVector<T> & PIVector<T>::fill(const T & f) { \
for (size_t i = 0; i < piv_size; ++i) \
piv_data[i] = f; \
return *this; \
} \
template<> inline PIVector<T> & PIVector<T>::resize(size_t new_size, const T & f) { \
if (new_size < piv_size) \
piv_size = new_size; \
if (new_size > piv_size) { \
size_t os = piv_size; \
alloc(new_size); \
for (size_t i = os; i < new_size; ++i) piv_data[i] = f; \
} \
return *this; \
} \
template<> inline PIVector<T> & PIVector<T>::insert(size_t index, const T & v) { \
alloc(piv_size + 1); \
if (index < piv_size - 1) { \
size_t os = piv_size - index - 1; \
memmove(&(piv_data[index + 1]), &(piv_data[index]), os * sizeof(T)); \
} \
piv_data[index] = v; \
return *this; \
} \
template<> inline PIVector<T> & PIVector<T>::remove(size_t index, size_t count) { \
if (index + count >= piv_size) { \
resize(index); \
return *this; \
} \
size_t os = piv_size - index - count; \
memmove(&(piv_data[index]), &(piv_data[index + count]), os * sizeof(T)); \
piv_size -= count; \
return *this; \
}
__PIVECTOR_SIMPLE_FUNCTIONS__(char)
__PIVECTOR_SIMPLE_FUNCTIONS__(uchar)
__PIVECTOR_SIMPLE_FUNCTIONS__(short)
__PIVECTOR_SIMPLE_FUNCTIONS__(ushort)
__PIVECTOR_SIMPLE_FUNCTIONS__(int)
__PIVECTOR_SIMPLE_FUNCTIONS__(uint)
__PIVECTOR_SIMPLE_FUNCTIONS__(long)
__PIVECTOR_SIMPLE_FUNCTIONS__(ulong)
__PIVECTOR_SIMPLE_FUNCTIONS__(llong)
__PIVECTOR_SIMPLE_FUNCTIONS__(ullong)
__PIVECTOR_SIMPLE_FUNCTIONS__(float)
__PIVECTOR_SIMPLE_FUNCTIONS__(double)
__PIVECTOR_SIMPLE_FUNCTIONS__(ldouble)
#else
@@ -425,15 +477,17 @@ public:
#endif
};
#define __PIVECTOR_SIMPLE_FUNCTIONS__(T)
#endif
template<typename T>
inline std::ostream & operator <<(std::ostream & s, const PIVector<T> & v) {s << "{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
inline std::ostream & operator <<(std::ostream & s, const PIVector<T> & v) {s << "{"; for (size_t i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; return s;}
template<typename T>
inline PICout operator <<(PICout s, const PIVector<T> & v) {s.space(); s.setControl(0, true); s << "{"; for (uint i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
inline PICout operator <<(PICout s, const PIVector<T> & v) {s.space(); s.setControl(0, true); s << "{"; for (size_t i = 0; i < v.size(); ++i) {s << v[i]; if (i < v.size() - 1) s << ", ";} s << "}"; s.restoreControl(); return s;}
#endif // PIVECTOR_H