Jump to content
  • Advertisement
Sign in to follow this  
giugio

lightweight list and hashtable for c++

This topic is 2259 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!