git-svn-id: svn://db.shs.com.ru/pip@185 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#define PIDEQUE_H
|
||||
|
||||
#include "piincludes.h"
|
||||
#include "piintrospection_proxy.h"
|
||||
|
||||
|
||||
#if !defined(PIP_CONTAINERS_STL) || defined(DOXYGEN)
|
||||
@@ -35,27 +36,33 @@ template <typename T>
|
||||
class PIDeque {
|
||||
public:
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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() {
|
||||
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);
|
||||
deleteT(pid_data + pid_start, pid_size);
|
||||
dealloc();
|
||||
@@ -197,6 +204,7 @@ public:
|
||||
alloc(new_size, true);
|
||||
//if (sizeof(T) == 1) memset(&(pid_data[os]), f, ds);
|
||||
//zeroRaw(&(pid_data[os]), new_size - os);
|
||||
PIINTROSPECTION_CONTAINER_USED((new_size-os)*sizeof(T))
|
||||
for (size_t i = os + pid_start; i < new_size + pid_start; ++i) elementNew(pid_data + i, f);
|
||||
}
|
||||
return *this;
|
||||
@@ -225,6 +233,7 @@ public:
|
||||
memmove(&(pid_data[pid_start]), &(pid_data[pid_start + 1]), index * sizeof(T));
|
||||
}
|
||||
//piCout << "insert" << pid_start << index << (pid_start + ssize_t(index)) << pid_size << ">!";
|
||||
PIINTROSPECTION_CONTAINER_USED(sizeof(T))
|
||||
elementNew(pid_data + pid_start + index, v);
|
||||
return *this;
|
||||
}
|
||||
@@ -330,6 +339,7 @@ private:
|
||||
return (1 << t);
|
||||
}
|
||||
inline void newT(T * dst, const T * src, size_t s) {
|
||||
PIINTROSPECTION_CONTAINER_USED(s*sizeof(T))
|
||||
for (size_t i = 0; i < s; ++i)
|
||||
elementNew(dst + i, src[i]);
|
||||
}
|
||||
@@ -346,6 +356,7 @@ private:
|
||||
else pid_tdata = (T*)(realloc(pid_tdata, s * sizeof(T)));
|
||||
}*/
|
||||
inline void deleteT(T * d, size_t sz) {
|
||||
PIINTROSPECTION_CONTAINER_UNUSED(sz*sizeof(T))
|
||||
//std::cout << " ~[("<<this<<")deleteT " << std::dec << sz << " elements " << " start " << pid_start << std::hex << " 0x" << (llong)d << " ... <" << std::endl;
|
||||
if ((uchar*)d != 0) {
|
||||
for (size_t i = 0; i < sz; ++i)
|
||||
@@ -407,6 +418,7 @@ private:
|
||||
size_t as = asize(pid_start + new_size);
|
||||
if (as != pid_rsize) {
|
||||
//printf("(%p) realloc %d -> %d (%p)\n", this, pid_rsize, as, pid_data);
|
||||
PIINTROSPECTION_CONTAINER_ALLOC((as-pid_rsize)*sizeof(T))
|
||||
pid_data = (T*)(realloc(pid_data, as*sizeof(T)));
|
||||
pid_rsize = as;
|
||||
//printf("(%p) realloc done (%p)\n", this, pid_data);
|
||||
@@ -425,6 +437,7 @@ private:
|
||||
T * td = newRaw(as);
|
||||
ssize_t ns = pid_start + as - pid_rsize;
|
||||
//printf("%X pid_start ost=%d ors=%d nst=%d nrs=%d\n", this, pid_start, pid_rsize, ns, as);
|
||||
PIINTROSPECTION_CONTAINER_ALLOC((as-pid_rsize)*sizeof(T))
|
||||
if (pid_rsize > 0 && pid_data != 0) {
|
||||
//printf("%X copy from %p + %d to %p + %d %d el\n", this, pid_data, pid_start, td, ns, pid_size);
|
||||
memcpy(td + ns, pid_data + pid_start, pid_size * sizeof(T));
|
||||
|
||||
Reference in New Issue
Block a user