Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

lightweight list and hashtable for c++


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 giugio   Members   -  Reputation: 182

Like
0Likes
Like

Posted 17 July 2012 - 06:43 AM

hello.
I'm need of some c++ raw data structures like a list and an hashtable , but without the overhead of stl.
I wish use these structures for containing raw data(point or vector 3d) for 3d models without no other purpose(like function objects ,and other stl functions).
for the list i can do it myself, but for the hashtable i have more problem.
But i ask if there are some library already done , for not reinvent the wheel
Thanks.

Ad:

#2 Hodgman   Moderators   -  Reputation: 13525

Like
1Likes
Like

Posted 17 July 2012 - 06:49 AM

The STL shouldn't have much overhead at all if you turn off all debugging features, which is tedious on some compilers.
I've used a lightweight replacement before called RDESTL, which I'd recommend if that's what you're looking for.

I use my own experimental lightweight hashtable (here, here), which only supports lookups and (optionally thread-safe) insertion.

Edited by Hodgman, 17 July 2012 - 06:54 AM.


#3 Bill Door   Members   -  Reputation: 143

Like
0Likes
Like

Posted 17 July 2012 - 11:31 AM

The question would be why do you think STL has "overhead"? Each container has it's expected expectations and limitations. Understand the expectations and limitations to make your decisions.

The c++2011 defines an unordered map (aka hashtable). If you're not using a C++-2011 installation, then you should be able to find something compatible (e.g. boost).

#4 sofla   Members   -  Reputation: 117

Like
0Likes
Like

Posted 17 July 2012 - 01:13 PM

If you can't wait for c++2011 and you are using a somewhat recent gcc or msvc, they both have hashtables as part of the library. The interfaces are even mostly compatible with each other.

If you don't want STL then roll your own. Most libraries will have "overhead" in the sense that it will have features that you don't intend to use.

Eventually you will get bored with writing your Nth inefficient list or hash you will start using canned libraries (ex: STL) like everyone else. Sure once in awhile you will have a "hot" data structure that warrants a handcrafted data structure but that is usually not the case.

#5 Acotoz   Members   -  Reputation: 73

Like
0Likes
Like

Posted 17 July 2012 - 05:51 PM

I needed some data structures a couple of years ago, and I didn't feel comfortable using STL, so I wrote them myself.

If you write them yourself, you will know the weaknesses and advantages of it, and also they are custom made, so there's a small sense of satisfaction.

But I would stick to everybody else's opinion, use STL they don't cause that much overhead you think they cause.

#6 alnite   Members   -  Reputation: 1396

Like
0Likes
Like

Posted 18 July 2012 - 12:54 AM

hello.
I'm need of some c++ raw data structures like a list and an hashtable , but without the overhead of stl.
I wish use these structures for containing raw data(point or vector 3d) for 3d models without no other purpose(like function objects ,and other stl functions).
for the list i can do it myself, but for the hashtable i have more problem.
But i ask if there are some library already done , for not reinvent the wheel
Thanks.


STL overhead is minimal, far smaller than you would've been able to get if you wrote it yourself. Function objects and other functions don't make your code slower, only slightly bigger, by a few bytes. The compiler might even have options to remove them automatically if you don't use it. Your textures take up more space than the entire STL library.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS