|
-
January 3rd, 2012, 03:02 AM
#10
Re: A faster std::set?
 Originally Posted by m1cha3l
This is an assignment I have been given ("make it faster!"). The requirement is to store large numbers of these range sets in memory.
Are you sure your algorithm is optimal? Step one of making things faster is having the best algorithm. Forget your code for just a minute and see of you can't do things smarter. You mentioned ranges, which probably means your problem is complex, but the good news is that it also means there might be better mathematical solutions.
****-written code backed-up with a good algorithm will ALWAYS cream hands down a bad algorithm, even with the most optimized code ever.
Algorithmic problems are always (IMO) the most fun. I'd help, but you haven't posted what you are actually trying to do :(
 Originally Posted by m1cha3l
I need to do some profiling, too, but my manager seems to think std::set can be rewritten to make it more efficient.
"std::set" was written as best as it can be. If you rewrite it, and get something faster, then you didn't rewrite std::set, you created something... different. If you find std::set is not fast enough for you, then blame your choice of container, NOT the implementation of set.
----
How large is your collection of data? Would using an std::unordered_set (hash container) help? You should be able to migrate to one with minimal effort. std::unordered_set is available with C++11, but you can find an equivalent implementation at boost::hash_set.
----
Writing (or rewriting) your own container should really be last thing you should try, after you are certain there are no better ways to speed up your code.
That said, if you a are certain it is the only way, and have a good rationale for it, I wouldn't mind helping you find a good data structure.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|