@MiiniPaa
Well, this is my fault because of the lack of explanation.
Im sorry about that but anyways.
First, am i right that
std::bitset<8> a;
a[0] = 1 <-- that will cost the speed of function?
because operator [] is the function not like in example
int u[8]
u[1] = 1 <<-- this.
I'm writing new compression thingy.
code:
http://pastebin.com/xHCSjti1
The code doesn't work tho.
Need to recode everything because im terrible.
The idea is to make normal data what is 1D to 2D like this:
123412341234123412341234
to this:
1234
1234
1234
1234
1234
1234
then check the elements from up to down.
let the x be width and let the y be height.
This is how i would check the numbers:
1 2 3 4 5 6 7 8 9
|
int x, y;
char data[24]; // inside of this are numbers: 12341234...
for( x = 0; x < 4; x++ )
{
for( y = 0; y < 6; y++ )
{
if( data[x+(y*4)] )
}
}
|
But instead of checking numbers, i check bits.
I'm not sure how nice my data compressor will be but
watching how bits nest in files, my idea could not turn out to be
a waste of time.
Btw this is how i check bits right now:
|
if( data[(x/8)+(y*4)] & (1 << x % 8) )
|
I think that there might be a better way to do this.
Faster way...
I have been thinking about the ways for 2 days now and
the best solution is the one i have right now.
Sure i could check all 8bits with few operator call like this:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
char prevchanges;
char changes;
char a;
char b;
changes = a ^ b
if(changes != prevchanges) // something has change
// this is what it should do:
// 01110010 ^
// 10101010
// ------------
// 11011000
|
The problems with that would be that it would be rather too
complicated to write a logic code what decompressor can understand.
Also taking this a count that the goal is to use smallest possible data amount to mark down the ways what decompressor would understand and know how to decompress the whole data.