Alternative for std::vector/STL?

Started by
30 comments, last by rick_appleton 17 years, 11 months ago
Quote:Original post by TheTroll
The reason I said write a "vector" class is so that he would write a class using the same naming convntion and functions that he is used to.

theTroll


When looking for a class with the same performance characteristics as a linked list he should be used to using std::list or std::slist. Well we should stop discussing this, since it's going off-topic I think.
Advertisement
Writing 64k demos is predominantly about minimizing code size. In these conditions using templates is sketchy because it expands binary size very quickly. It may actually be wiser to use type-unsafe void* based containers if you want to fit inside that 64 kilobyte cage.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Kitt3n
He doesn't mean overhead from the stl-vector implementation,
but space overhead from linking with the stl - which will make
his 64kb demo bigger (eg stlport.lib is 950 kb big).


When you link to a static library, you don't typically merge the whole library with your program, but only those bits you have used. Furthermore, it is my understanding that stlport.lib only contains precompiled iostream class instanciations (for char and wchar_t); std::vector is still pulled in and compiled from the source that is in the <vector> header.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Quote:Original post by TheTroll
You should just write your own vector class, in most cases it is just a linked list.



ROFL a STL vector is NEVER implemented as a linked list. That's just preposterous.
Quote:Original post by TheTroll
You should just write your own vector class, in most cases it is just a linked list. If you need any advice on how to make it just let us know.

theTroll


If you write vector classes as linked lists. How then do you solve the O(1) access time that vectors are supposed to boast...
not even 'supposed to boast', more like 'required to have'.
Avoiding STL containers because they could be bloated is a typical premature optimization.
It should be easy to write some code using std::vector and inspect the size of what std::vector specializations compile to; in a 64k demo this kind of analysis is likely to be required anyway.

[Edited by - LorenzoGatti on May 2, 2006 11:59:37 AM]

Omae Wa Mou Shindeiru

It's not the bloat of vector it's from the fact, that you have duplicated code fpr every instanziation. Therefore it is better to use a generic void* vector and then cast it to the right type (this could be in a template, as mentioned some posts before).
Quote:Original post by Anonymous Poster
It's not the bloat of vector it's from the fact, that you have duplicated code fpr every instanziation. Therefore it is better to use a generic void* vector and then cast it to the right type (this could be in a template, as mentioned some posts before).


You don't think partial specialization is good enough? Could you post your profiling results?

Stephen M. Webb
Professional Free Software Developer

Quote:Original post by Bregma
Quote:Original post by Anonymous Poster
It's not the bloat of vector it's from the fact, that you have duplicated code fpr every instanziation. Therefore it is better to use a generic void* vector and then cast it to the right type (this could be in a template, as mentioned some posts before).


You don't think partial specialization is good enough? Could you post your profiling results?


The point is that even partial specialisation creates more code than using a generic void*. For every type he wants to use, the preprocessor will generate the code to handle that type. That's what templates do, and as remarkably useful as they are, they do increase code-size. It's not about speed (unless you meant code-size when talking about "profiling", in which case, you know that already).
[ search: google ][ programming: msdn | boost | opengl ][ languages: nihongo ]

This topic is closed to new replies.

Advertisement