diff --git a/pip.cbp b/pip.cbp
index 8c31f43b..ce27b326 100644
--- a/pip.cbp
+++ b/pip.cbp
@@ -5,7 +5,7 @@
-
+
@@ -17,56 +17,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -78,18 +28,13 @@
+
-
-
-
-
-
-
@@ -109,18 +54,13 @@
+
-
-
-
-
-
-
@@ -140,18 +80,13 @@
+
-
-
-
-
-
-
@@ -171,18 +106,13 @@
+
-
-
-
-
-
-
@@ -191,16 +121,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -212,18 +132,13 @@
+
-
-
-
-
-
-
@@ -243,18 +158,13 @@
+
-
-
-
-
-
-
@@ -274,18 +184,13 @@
+
-
-
-
-
-
-
@@ -305,18 +210,13 @@
+
-
-
-
-
-
-
@@ -336,18 +236,13 @@
+
-
-
-
-
-
-
@@ -367,18 +262,13 @@
+
-
-
-
-
-
-
@@ -387,13 +277,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -402,6 +358,8 @@
+
+
@@ -414,12 +372,16 @@
+
+
+
+
@@ -428,6 +390,8 @@
+
+
@@ -454,9 +418,7 @@
-
-
-
+
@@ -464,6 +426,8 @@
+
+
@@ -478,14 +442,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -494,6 +478,8 @@
+
+
@@ -506,12 +492,16 @@
+
+
+
+
@@ -520,6 +510,8 @@
+
+
@@ -546,9 +538,7 @@
-
-
-
+
@@ -556,6 +546,8 @@
+
+
@@ -566,17 +558,170 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/containers/pideque.h b/src/containers/pideque.h
index 00eb0941..26291534 100755
--- a/src/containers/pideque.h
+++ b/src/containers/pideque.h
@@ -36,7 +36,7 @@ class PIDeque {
public:
PIDeque(): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
//printf("new vector 1 %p (%s) ... !{\n", this, typeid(T).name());
- //printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
+ //printf("(s=%d, d=%p) }!\n", int(pid_size), pid_data);
}
PIDeque(const PIDeque & other): pid_data(0), pid_size(0), pid_rsize(0), pid_start(0) {
//printf("new vector 2 %p (%s) ... !{\n", this, typeid(T).name());
@@ -201,7 +201,13 @@ public:
}
return *this;
}
- PIDeque & reserve(size_t new_size) {if (new_size <= pid_rsize) return *this; size_t os = pid_size; alloc(new_size, true); pid_size = os; return *this;}
+ PIDeque & reserve(size_t new_size) {
+ if (new_size <= pid_rsize) return *this;
+ size_t os = pid_size;
+ alloc(new_size, true);
+ pid_size = os;
+ return *this;
+ }
PIDeque & insert(size_t index, const T & v = T()) {
bool dir = pid_rsize <= 2 ? true : (index >= pid_rsize / 2 ? true : false);
@@ -210,11 +216,10 @@ public:
alloc(pid_size + 1, true);
if (index < pid_size - 1) {
size_t os = pid_size - index - 1;
- memmove(&(pid_data[pid_start + index + 1]), &(pid_data[pid_start + index]), os * sizeof(T));
+ memmove(&(pid_data[index + pid_start + 1]), &(pid_data[index + pid_start]), os * sizeof(T));
}
} else {
- pid_start--;
- alloc(pid_size + 1, false);
+ alloc(pid_size + 1, false, -1);
//piCout << "insert front" << pid_size << pid_rsize << pid_start << "!<";
if (index > 0)
memmove(&(pid_data[pid_start]), &(pid_data[pid_start + 1]), index * sizeof(T));
@@ -226,20 +231,22 @@ public:
PIDeque & insert(size_t index, const PIDeque & other) {
if (other.isEmpty()) return *this;
bool dir = pid_rsize <= 2 ? true : (index >= pid_rsize / 2 ? true : false);
- //piCout << "insert" << dir << index << pid_size << pid_rsize << pid_start << "!<";
+ //piCout << this << "insert" << dir << index << pid_size << pid_rsize << pid_start << " <- " << other.size() << "!<";
if (dir) {
ssize_t os = pid_size - index;
alloc(pid_size + other.pid_size, true);
if (os > 0)
- memmove(&(pid_data[pid_start + index + other.pid_size]), &(pid_data[pid_start + index]), os * sizeof(T));
+ memmove(&(pid_data[index + pid_start + other.pid_size]), &(pid_data[index + pid_start]), os * sizeof(T));
} else {
- pid_start -= other.pid_size;
- alloc(pid_size + other.pid_size, false);
- //piCout << "insert front" << pid_size << pid_rsize << pid_start << "!<";
+ //if (pid_start < other.pid_size) pid_start = 0;
+ //piCout << this << " insert offseted start ba" << pid_start << pid_size << pid_rsize;
+ alloc(pid_size + other.pid_size, false, -other.pid_size);
+ //piCout << this << " insert offseted start aa" << pid_start << pid_size << pid_rsize;
+ //piCout << this << " insert front" << pid_size << pid_rsize << pid_start << "!<";
if (index > 0)
memmove(&(pid_data[pid_start]), &(pid_data[pid_start + other.pid_size]), index * sizeof(T));
}
- //piCout << "insert" << pid_start << index << (pid_start + ssize_t(index)) << pid_size << ">!";
+ //piCout << this << "insert" << pid_start << index << (pid_start + ssize_t(index)) << pid_size << ">!";
newT(pid_data + pid_start + index, other.pid_data + other.pid_start, other.pid_size);
return *this;
}
@@ -251,10 +258,10 @@ public:
return *this;
}
size_t os = pid_size - index - count;
- deleteT(&(pid_data[pid_start + index]), count);
+ deleteT(&(pid_data[index + pid_start]), count);
if (os <= index) {
//if (true) {
- if (os > 0) memmove(&(pid_data[pid_start + index]), &(pid_data[pid_start + index + count]), os * sizeof(T));
+ if (os > 0) memmove(&(pid_data[index + pid_start]), &(pid_data[index + pid_start + count]), os * sizeof(T));
} else {
if (index > 0) memmove(&(pid_data[pid_start + count]), &(pid_data[pid_start]), index * sizeof(T));
pid_start += count;
@@ -327,11 +334,11 @@ private:
elementNew(dst + i, src[i]);
}
inline T * newRaw(size_t s) {
- //cout << std::dec << " ![("< (new 0x" << (llong)ret << ") ok]!" << endl;
+ //std::cout << std::hex << " > (new 0x" << (llong)ret << ") ok]!" << std::endl;
return (T*)ret;
}
/*void reallocRawTemp(size_t s) {
@@ -339,7 +346,7 @@ private:
else pid_tdata = (T*)(realloc(pid_tdata, s * sizeof(T)));
}*/
inline void deleteT(T * d, size_t sz) {
- //cout << " ~[("<= 4 && pid_size < pid_rsize / 4) {
+ if (pid_size >= 4 && pid_size < pid_rsize / 6) {
/*if (direction) {
if (pid_start >= 4 && pid_start > pid_size + pid_size && pid_start > pid_rsize / 2) {
piCout << (int)this << "checkMove" << direction << pid_start << (int)pid_data << pid_rsize << pid_size;
@@ -378,16 +385,18 @@ private:
pid_start = ssize_t(pid_rsize) - pid_size - pid_size;
}
}*/
+ //printf("(%p) check move st=%d sz=%d rs=%d\n", this, pid_start, pid_size, pid_rsize);
if (pid_start < pid_size + pid_size || pid_start > pid_rsize - pid_size - pid_size) {
- size_t ns = (pid_rsize - pid_size) / 2;
+ ssize_t ns = (pid_rsize - pid_size) / 2;
if (pid_start != ns) {
+ //printf("(%p) move %d -> %d\n", this, pid_start, ns);
memmove(pid_data + ns, pid_data + pid_start, pid_size * sizeof(T));
pid_start = ns;
}
}
}
}
- inline void alloc(size_t new_size, bool direction) { // direction == true -> alloc forward
+ inline void alloc(size_t new_size, bool direction, ssize_t start_offset = 0) { // direction == true -> alloc forward
if (direction) {
if (pid_start + new_size <= pid_rsize) {
pid_size = new_size;
@@ -397,42 +406,46 @@ private:
pid_size = new_size;
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);
pid_data = (T*)(realloc(pid_data, as*sizeof(T)));
pid_rsize = as;
+ //printf("(%p) realloc done (%p)\n", this, pid_data);
}
} else {
- size_t as = asize(piMax(new_size, pid_rsize) - pid_start);
- //piCout << "alloc" << new_size << pid_size << pid_rsize << as << pid_start;
- if (pid_start >= 0 && as <= pid_rsize) {
- pid_size = new_size;
- checkMove(direction);
- return;
- }
- size_t os = pid_size;
- pid_size = new_size;
+ size_t as;
+ //piCout << "INS ba" << *this;
+ if (pid_start + start_offset < 0)
+ as = asize(pid_rsize - start_offset);
+ else as = pid_rsize;
+ //printf("%X alloc %d %d\n", this, pid_rsize, start_offset);
+ //printf("%X alloc %d %d %d %d %d %d\n", this, new_size, pid_size, pid_rsize, as, pid_start, start_offset);
if (as > pid_rsize) {
- //piCout << "alloc new size" << as;
+ //printf("%X alloc new size %d\n", this, as);
//cout << std::hex << " ![("< 0 && pid_data != 0) {
- memcpy(td + pid_start + ns, pid_data + ost, os * sizeof(T));
+ 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);
+ 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));
deleteRaw(pid_data);
}
pid_data = td;
pid_rsize = as;
+ pid_start = ns;
+ //piCout << "INS aa" << *this;
}
+ pid_start += start_offset;
+ pid_size = new_size;
+ checkMove(direction);
}
//checkMove(direction);
- //piCout << "alloc new start" << pid_start;
+ //printf("%X alloc new start %d\n", this, pid_start);
}
T * pid_data;
volatile size_t pid_size, pid_rsize;
- volatile size_t pid_start;
+ volatile ssize_t pid_start;
};
#define __PIDEQUE_SIMPLE_TYPE__(T) \
diff --git a/src/pip_version_str.h b/src/pip_version_str.h
deleted file mode 100644
index 51858e6f..00000000
--- a/src/pip_version_str.h
+++ /dev/null
@@ -1,2 +0,0 @@
-// This file was generated by PIP CMake, don`t edit it!
-#define __PIP_VERSION_STR__ "0.5.0_alpha"