git-svn-id: svn://db.shs.com.ru/pip@468 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
7
main.cpp
7
main.cpp
@@ -40,9 +40,10 @@ public:
|
||||
};
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
PIThread t;
|
||||
PIObject * o = (PIObject*)&t;
|
||||
piCout << (o->cast<PIObject>());
|
||||
PIVariant v;
|
||||
A a = v.value<A>();
|
||||
// v = PIVariant::fromValue(a);
|
||||
|
||||
|
||||
// PIDiagnostics d;
|
||||
// piCout << d.receiveBytesPerSec();
|
||||
|
||||
@@ -35,32 +35,32 @@
|
||||
template <typename T>
|
||||
class PIDeque {
|
||||
public:
|
||||
PIDeque(): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
inline PIDeque(): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
PIINTROSPECTION_CONTAINER_NEW()
|
||||
//printf("new vector 1 %p (%s) ... !{\n", this, typeid(T).name());
|
||||
//printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
|
||||
}
|
||||
PIDeque(const PIDeque<T> & other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
inline PIDeque(const PIDeque<T> & other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
PIINTROSPECTION_CONTAINER_NEW()
|
||||
//printf("new vector 2 %p (%s) ... !{\n", this, typeid(T).name());
|
||||
alloc(other.pid_size, true);
|
||||
newT(pid_data + pid_start, other.pid_data + other.pid_start, pid_size);
|
||||
//printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
|
||||
}
|
||||
PIDeque(const T * data, size_t size): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
inline PIDeque(const T * data, size_t size): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
PIINTROSPECTION_CONTAINER_NEW()
|
||||
//printf("new vector 2 %p (%s) ... !{\n", this, typeid(T).name());
|
||||
alloc(size, true);
|
||||
newT(pid_data + pid_start, data, pid_size);
|
||||
//printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
|
||||
}
|
||||
PIDeque(size_t pid_size, const T & f = T()): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
inline PIDeque(size_t pid_size, const T & f = T()): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
|
||||
PIINTROSPECTION_CONTAINER_NEW()
|
||||
//printf("new vector 3 %p (%s) ... !{\n", this, typeid(T).name());
|
||||
resize(pid_size, f);
|
||||
//printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
|
||||
}
|
||||
~PIDeque() {
|
||||
inline ~PIDeque() {
|
||||
PIINTROSPECTION_CONTAINER_DELETE()
|
||||
PIINTROSPECTION_CONTAINER_FREE((pid_rsize)*sizeof(T))
|
||||
//printf("delete deque %p (%s) (s=%d, rs=%d, st=%d, d=%p) ... ~{\n", this, typeid(T).name(), int(pid_size), int(pid_rsize), int(pid_start), pid_data);
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
//printf("}~\n");
|
||||
}
|
||||
|
||||
PIDeque<T> & operator =(const PIDeque<T> & other) {
|
||||
inline PIDeque<T> & operator =(const PIDeque<T> & other) {
|
||||
if (this == &other) return *this;
|
||||
deleteT(pid_data + pid_start, pid_size);
|
||||
alloc(other.pid_size, true);
|
||||
@@ -184,8 +184,8 @@ public:
|
||||
|
||||
T * data(size_t index = 0) {return &(pid_data[pid_start + index]);}
|
||||
const T * data(size_t index = 0) const {return &(pid_data[pid_start + index]);}
|
||||
PIDeque<T> & clear() {resize(0); return *this;}
|
||||
PIDeque<T> & fill(const T & f = T()) {
|
||||
inline PIDeque<T> & clear() {resize(0); return *this;}
|
||||
inline PIDeque<T> & fill(const T & f = T()) {
|
||||
//if (sizeof(T) == 1) memset(pid_data, f, pid_size);
|
||||
deleteT(pid_data + pid_start, pid_size);
|
||||
//zeroRaw(pid_data, pid_size);
|
||||
@@ -193,9 +193,10 @@ public:
|
||||
elementNew(pid_data + i, f);
|
||||
return *this;
|
||||
}
|
||||
PIDeque<T> & assign(const T & f = T()) {return fill(f);}
|
||||
PIDeque<T> & assign(size_t new_size, const T & f) {resize(new_size); return fill(f);}
|
||||
PIDeque<T> & resize(size_t new_size, const T & f = T()) {
|
||||
inline PIDeque<T> & assign(const T & f = T()) {return fill(f);}
|
||||
inline PIDeque<T> & assign(size_t new_size, const T & f) {resize(new_size); return fill(f);}
|
||||
|
||||
inline PIDeque<T> & resize(size_t new_size, const T & f = T()) {
|
||||
if (new_size < pid_size) {
|
||||
deleteT(&(pid_data[new_size + pid_start]), pid_size - new_size);
|
||||
pid_size = new_size;
|
||||
@@ -210,7 +211,13 @@ public:
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
PIDeque<T> & reserve(size_t new_size) {
|
||||
inline PIDeque<T> & _resizeRaw(size_t new_size) {
|
||||
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIDEQUE_SIMPLE_TYPE__ macro!";
|
||||
assert(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline PIDeque<T> & reserve(size_t new_size) {
|
||||
if (new_size <= pid_rsize) return *this;
|
||||
size_t os = pid_size;
|
||||
alloc(new_size, true);
|
||||
@@ -218,7 +225,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
PIDeque<T> & insert(size_t index, const T & v = T()) {
|
||||
inline PIDeque<T> & insert(size_t index, const T & v = T()) {
|
||||
bool dir = pid_rsize <= 2 ? true : (index >= pid_rsize / 2 ? true : false);
|
||||
//piCout << "insert" << dir << index << pid_size << pid_rsize << pid_start << "!<";
|
||||
if (dir) {
|
||||
@@ -238,7 +245,7 @@ public:
|
||||
elementNew(pid_data + pid_start + index, v);
|
||||
return *this;
|
||||
}
|
||||
PIDeque<T> & insert(size_t index, const PIDeque<T> & other) {
|
||||
inline PIDeque<T> & insert(size_t index, const PIDeque<T> & other) {
|
||||
if (other.isEmpty()) return *this;
|
||||
bool dir = pid_rsize <= 2 ? true : (index >= pid_rsize / 2 ? true : false);
|
||||
//piCout << this << "insert" << dir << index << pid_size << pid_rsize << pid_start << " <- " << other.size() << "!<";
|
||||
@@ -261,7 +268,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
PIDeque<T> & remove(size_t index, size_t count = 1) {
|
||||
inline PIDeque<T> & remove(size_t index, size_t count = 1) {
|
||||
if (count == 0) return *this;
|
||||
if (index + count >= pid_size) {
|
||||
resize(index);
|
||||
@@ -280,7 +287,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(PIDeque<T> & other) {
|
||||
inline void swap(PIDeque<T> & other) {
|
||||
piSwap<T*>(pid_data, other.pid_data);
|
||||
piSwap<size_t>(pid_size, other.pid_size);
|
||||
piSwap<size_t>(pid_rsize, other.pid_rsize);
|
||||
@@ -384,7 +391,7 @@ private:
|
||||
}
|
||||
inline void elementNew(T * to, const T & from) {new(to)T(from);}
|
||||
inline void elementDelete(T & from) {from.~T();}
|
||||
void dealloc() {deleteRaw(pid_data);}
|
||||
inline void dealloc() {deleteRaw(pid_data);}
|
||||
inline void checkMove(bool direction) {
|
||||
if (pid_size >= 4) {
|
||||
if (pid_size < pid_rsize / 6) {
|
||||
@@ -474,15 +481,19 @@ private:
|
||||
}
|
||||
|
||||
T * pid_data;
|
||||
volatile size_t pid_size, pid_rsize;
|
||||
volatile ssize_t pid_start;
|
||||
size_t pid_size, pid_rsize;
|
||||
ssize_t pid_start;
|
||||
};
|
||||
|
||||
#define __PIDEQUE_SIMPLE_TYPE__(T) \
|
||||
template<> inline void PIDeque<T>::newT(T * dst, const T * src, size_t s) {PIINTROSPECTION_CONTAINER_USED(s*sizeof(T)); memcpy(dst, src, s * sizeof(T));} \
|
||||
template<> inline void PIDeque<T>::deleteT(T * d, size_t sz) {PIINTROSPECTION_CONTAINER_UNUSED(sz*sizeof(T));} \
|
||||
template<> inline void PIDeque<T>::elementNew(T * to, const T & from) {(*to) = from;} \
|
||||
template<> inline void PIDeque<T>::elementDelete(T & from) {;}
|
||||
template<> inline void PIDeque<T>::elementDelete(T & from) {;} \
|
||||
template<> inline PIDeque<T> & PIDeque<T>::_resizeRaw(size_t new_size) {if (new_size > pid_size) alloc(new_size, true); return *this;} \
|
||||
template<> inline PIDeque<T> & PIDeque<T>::clear() {pid_size = 0; return *this;} \
|
||||
template<> inline PIDeque<T> & PIDeque<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -33,28 +33,28 @@
|
||||
template <typename T>
|
||||
class PIVector {
|
||||
public:
|
||||
PIVector(): piv_data(0), piv_size(0), piv_rsize(0) {
|
||||
inline 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);
|
||||
}
|
||||
PIVector(const T * data, size_t size): piv_data(0), piv_size(0), piv_rsize(0) {
|
||||
inline PIVector(const T * data, size_t size): piv_data(0), piv_size(0), piv_rsize(0) {
|
||||
//printf("new vector 2 %p (%s) ... !{\n", this, typeid(T).name());
|
||||
alloc(size);
|
||||
newT(piv_data, data, piv_size);
|
||||
//printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
|
||||
}
|
||||
PIVector(const PIVector<T> & other): piv_data(0), piv_size(0), piv_rsize(0) {
|
||||
inline 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);
|
||||
newT(piv_data, other.piv_data, piv_size);
|
||||
//printf("(s=%d, d=%p) }!\n", int(piv_size), piv_data);
|
||||
}
|
||||
PIVector(size_t piv_size, const T & f = T()): piv_data(0), piv_size(0), piv_rsize(0) {
|
||||
inline 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);
|
||||
}
|
||||
~PIVector() {
|
||||
inline ~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);
|
||||
dealloc();
|
||||
@@ -63,33 +63,12 @@ public:
|
||||
//printf("}~\n");
|
||||
}
|
||||
|
||||
PIVector<T> & operator =(const PIVector<T> & other) {
|
||||
inline 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));
|
||||
if (tj) {
|
||||
//printf("JUNK this\n");
|
||||
_reset();
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
/*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) {
|
||||
deleteT(piv_data, piv_size);
|
||||
alloc(other.piv_size);
|
||||
//zeroRaw(piv_data, piv_size);
|
||||
for (size_t i = 0; i < piv_size; ++i)
|
||||
elementNew(piv_data + i, other.piv_data[i]); //piv_data[i] = other.piv_data[i];
|
||||
} else {
|
||||
//printf("JUNK other\n");
|
||||
}
|
||||
//printf("o]\n");
|
||||
clear();
|
||||
deleteT(piv_data, piv_size);
|
||||
alloc(other.piv_size);
|
||||
newT(piv_data, other.piv_data, piv_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -199,8 +178,8 @@ public:
|
||||
|
||||
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()) {
|
||||
inline PIVector<T> & clear() {resize(0); return *this;}
|
||||
inline 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);
|
||||
@@ -208,9 +187,10 @@ public:
|
||||
elementNew(piv_data + i, f);
|
||||
return *this;
|
||||
}
|
||||
PIVector<T> & assign(const T & f = T()) {return fill(f);}
|
||||
PIVector<T> & assign(size_t new_size, const T & f) {resize(new_size); return fill(f);}
|
||||
PIVector<T> & resize(size_t new_size, const T & f = T()) {
|
||||
inline PIVector<T> & assign(const T & f = T()) {return fill(f);}
|
||||
inline PIVector<T> & assign(size_t new_size, const T & f) {resize(new_size); return fill(f);}
|
||||
|
||||
inline 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);
|
||||
@@ -221,13 +201,26 @@ public:
|
||||
alloc(new_size);
|
||||
//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) elementNew(piv_data + i, f);
|
||||
for (size_t i = os; i < new_size; ++i)
|
||||
elementNew(piv_data + i, f);
|
||||
}
|
||||
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;}
|
||||
inline PIVector<T> & _resizeRaw(size_t new_size) {
|
||||
piCout << "Error, \"resizeRaw()\" only allowed for simple type declared with __PIVECTOR_SIMPLE_TYPE__ macro!";
|
||||
assert(0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PIVector<T> & insert(size_t index, const T & v = T()) {
|
||||
inline 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;
|
||||
}
|
||||
|
||||
inline 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;
|
||||
@@ -247,7 +240,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
PIVector<T> & remove(size_t index, size_t count = 1) {
|
||||
inline PIVector<T> & remove(size_t index, size_t count = 1) {
|
||||
if (count == 0) return *this;
|
||||
if (index + count >= piv_size) {
|
||||
resize(index);
|
||||
@@ -260,7 +253,7 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(PIVector<T> & other) {
|
||||
inline void swap(PIVector<T> & other) {
|
||||
piSwap<T*>(piv_data, other.piv_data);
|
||||
piSwap<size_t>(piv_size, other.piv_size);
|
||||
piSwap<size_t>(piv_rsize, other.piv_rsize);
|
||||
@@ -268,38 +261,38 @@ public:
|
||||
|
||||
typedef int (*CompareFunc)(const T * , const T * );
|
||||
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) {piqsort(piv_data, piv_size, sizeof(T), (int(*)(const void * , const void * ))compare); return *this;}
|
||||
inline PIVector<T> & sort(CompareFunc compare = compare_func) {piqsort(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(size_t(ns)); return *this;}
|
||||
inline 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 (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 (ssize_t i = 0; i < ssize_t(piv_size); ++i) if (piv_data[i] == v) {remove(i); --i;} return *this;}
|
||||
inline 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;}
|
||||
inline PIVector<T> & removeAll(const T & v) {for (ssize_t i = 0; i < ssize_t(piv_size); ++i) if (piv_data[i] == v) {remove(i); --i;} return *this;}
|
||||
|
||||
PIVector<T> & push_back(const T & v) {alloc(piv_size + 1); elementNew(piv_data + piv_size - 1, 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> & operator <<(const PIVector<T> & other) {
|
||||
inline PIVector<T> & push_back(const T & v) {alloc(piv_size + 1); elementNew(piv_data + piv_size - 1, v); return *this;}
|
||||
inline PIVector<T> & append(const T & v) {return push_back(v);}
|
||||
inline PIVector<T> & operator <<(const T & v) {return push_back(v);}
|
||||
inline PIVector<T> & operator <<(const PIVector<T> & other) {
|
||||
size_t ps = piv_size;
|
||||
alloc(piv_size + other.piv_size);
|
||||
newT(piv_data + ps, other.piv_data, other.piv_size);
|
||||
return *this;
|
||||
}
|
||||
|
||||
PIVector<T> & push_front(const T & v) {insert(0, v); return *this;}
|
||||
PIVector<T> & prepend(const T & v) {return push_front(v);}
|
||||
inline PIVector<T> & push_front(const T & v) {insert(0, v); return *this;}
|
||||
inline 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;}
|
||||
inline PIVector<T> & pop_back() {if (piv_size == 0) return *this; resize(piv_size - 1); return *this;}
|
||||
inline 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;}
|
||||
inline T take_back() {T t(back()); pop_back(); return t;}
|
||||
inline T take_front() {T t(front()); pop_front(); return t;}
|
||||
|
||||
template <typename ST>
|
||||
PIVector<ST> toType() const {PIVector<ST> ret(piv_size); for (uint i = 0; i < piv_size; ++i) ret[i] = ST(piv_data[i]); return ret;}
|
||||
|
||||
private:
|
||||
void _reset() {piv_size = piv_rsize = 0; piv_data = 0;}
|
||||
size_t asize(size_t s) {
|
||||
inline void _reset() {piv_size = piv_rsize = 0; piv_data = 0;}
|
||||
inline 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;
|
||||
@@ -311,7 +304,7 @@ private:
|
||||
for (size_t i = 0; i < s; ++i)
|
||||
elementNew(dst + i, src[i]);
|
||||
}
|
||||
T * newRaw(size_t s) {
|
||||
inline 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[];
|
||||
@@ -345,7 +338,7 @@ private:
|
||||
}
|
||||
inline void elementNew(T * to, const T & from) {new(to)T(from);}
|
||||
inline void elementDelete(T & from) {from.~T();}
|
||||
void dealloc() {deleteRaw(piv_data);}
|
||||
inline void dealloc() {deleteRaw(piv_data);}
|
||||
inline void alloc(size_t new_size) {
|
||||
if (new_size <= piv_rsize) {
|
||||
piv_size = new_size;
|
||||
@@ -373,7 +366,7 @@ private:
|
||||
}
|
||||
|
||||
T * piv_data;
|
||||
volatile size_t piv_size, piv_rsize;
|
||||
size_t piv_size, piv_rsize;
|
||||
};
|
||||
/*
|
||||
#define __PIVECTOR_SIMPLE_FUNCTIONS__(T) \
|
||||
@@ -432,7 +425,11 @@ __PIVECTOR_SIMPLE_FUNCTIONS__(ldouble)*/
|
||||
template<> inline void PIVector<T>::newT(T * dst, const T * src, size_t s) {memcpy(dst, src, s * sizeof(T));} \
|
||||
template<> inline void PIVector<T>::deleteT(T * d, size_t sz) {;} \
|
||||
template<> inline void PIVector<T>::elementNew(T * to, const T & from) {(*to) = from;} \
|
||||
template<> inline void PIVector<T>::elementDelete(T & from) {;}
|
||||
template<> inline void PIVector<T>::elementDelete(T & from) {;} \
|
||||
template<> inline PIVector<T> & PIVector<T>::_resizeRaw(size_t new_size) {alloc(new_size); return *this;} \
|
||||
template<> inline PIVector<T> & PIVector<T>::clear() {piv_size = 0; return *this;} \
|
||||
template<> inline PIVector<T> & PIVector<T>::assign(size_t new_size, const T & f) {_resizeRaw(new_size); return fill(f);}
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ __PICONTAINERS_SIMPLE_TYPE__(PIChar)
|
||||
template<> \
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIVector<T> & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
|
||||
template<> \
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;} \
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIVector<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v._resizeRaw(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;} \
|
||||
template<> \
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIDeque<T> & v) {s << int(v.size_s()); int os = s.size_s(); s.enlarge(v.size_s()*sizeof(T)); memcpy(s.data(os), v.data(), v.size_s()*sizeof(T)); return s;} \
|
||||
template<> \
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v.resize(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIDeque<T> & v) {assert(s.size_s() >= 4); int sz; s >> sz; v._resizeRaw(sz); if (sz > 0) memcpy(v.data(), s.data(), sz*sizeof(T)); s.remove(0, sz*sizeof(T)); return s;}
|
||||
|
||||
|
||||
class PIString;
|
||||
|
||||
@@ -212,7 +212,7 @@ private:
|
||||
inline complexd residue(const complexd & f, const complexd & s);
|
||||
inline void execFunction(const PIEvaluatorTypes::Instruction & ci);
|
||||
|
||||
PIVector<PIEvaluatorTypes::Element> elements;
|
||||
PIDeque<PIEvaluatorTypes::Element> elements;
|
||||
PIVector<PIEvaluatorTypes::Variable> currentVariables, variables, tmpvars, * kvars;
|
||||
PIVector<PIEvaluatorTypes::Instruction> instructions;
|
||||
PIStringList unknownVars;
|
||||
|
||||
Reference in New Issue
Block a user