I'm having one crazy idea how to boost the speed of moving.
Instead of moving data, we would move the pointer.
We need 2 arrays
T means datatype, it can be int, char or what ever data type/size
P means pointer of the data, its size is
32bit system: int
63bit system: long long int
Lets imagine that data is char and letters
T data = [a][b][c][d][e][f][g][h]
P pointer = [0][1][2][3][4][5][6][7]
to access my data i do this:
cout << "data:" (T)pointer[0] << endl;
now to remove first element i would do this:
1 2 3
|
element_to_remove = 0
datasize = 8
for( a = element_to_remove; a < datasize - 1; a++ ) pointer[a]++;
|
now things look like this:
T data = [a][b][c][d][e][f][g][h]
P pointer = [1][2][3][4][5][6][7][7]
cout << "data:" (T)pointer[0] << endl;
the problem is keeping track of empty or unused array places.
I need to write down those pointer values what i dont use anymore
so i could reuse them if i need them again.
For example i would need one what i removed when i push new item into my vector/array thingy.
I could do something like this:
1 2 3 4 5 6 7 8 9 10 11
|
myvectorsize = 8
T data[myvectorsize]
P pointer[myvectorsize]
P reserved[myvectorsize]
reservedsize = 0
// now lets remove first element:
item_to_remove = 0
reserved[reservedsize++] = pointer[item_to_remove];
for( a = item_to_remove; a < myvectorsize - 1; a++ ) pointer[a]++;
// Btw, pointer[a] += sizeof(t)
// just in case pointing that out...
|
but i would use so much memory :/
Thats one thing i suspected what vector was doing but i guess its not doing it.
(there are a lot of concepts and algo here to learn) |
Can you give me link for some?
I'm googling things yet i can't find anything what would help me to understand
the witchcraft of default vector.
Most of the thing i found point me into standard libraries what is not what i want.
I want to learn how one standard library works.
Others tell me the stuff i already know and have already used in this code:
http://pastebin.com/5Ri5Jxky