Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Linked vs Dynamic Array

Name: Anonymous 2011-12-12 20:01

In consideration of modern architectures and memory layout, are linked data structures ever worth it?
It feels like an dynamic array is a lot better in every sense.

Name: Anonymous 2011-12-13 20:48

>>34
Here is example of Bitmap struct as array:
Here is example of a Bitmap "struct array" as a struct:
struct Bitmap {
     char magic[2];
     uint32_t crfilesize, dummy, bitmapoffset, bhsize, w, h;
     uint16_t bitplanes, bitsperpixel;
     uint32_t compression, imagesize, xppm, yppm, numcolors, impcolors;
     int32_t colors;
     char padding[n]; //pad until STDOFFSET
     int32_t pixels;
};


Now if you have a compiler that isn't crap, you can do this:
bitmap = (struct Bitmap){
     .magic = "BM",
     .crfilesize = FILESIZE,
     .bitmapoffset = STDOFFSET,
     .bhsize = HEADERINFOSIZE,
     .w = DEFWRES,
     .h = DEFHRES,
     .bitplanes = 1,
     .bitsperpixel = BITSPERPIXEL,
     .compression = 0,
     .imagesize = SIZE,
     .xppm = STDPPM,
     .yppm = STDPPM,
     .numcolors = 256,
     .impcolors = 256
};
double off = 0;
uint32_t currframe = 0;
uint32_t i,c,m;
uint32_t x,y,height = bitmap.h, width = bitmap.w;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List