Archived

This topic is now archived and is closed to further replies.

C++ STL Binary Tree (Using a class member as the Key)?

This topic is 5153 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

Okay, I know what a binary tree is, how to make one, etc. I think that the std::map is generally implemented as a binary tree, correct? Well, I need to use a binary tree to keep some data sorted and quickly searchable, but the problem is that the key is in the class I need to serach, so using a map causes duplication of data. Is there any STL data structure that can keep a binary tree using a member of the class its storing as the key? I could create one myself if required, I just don't want to do extra work =-) [edited by - extrarius on November 7, 2003 3:23:21 PM]

Share this post


Link to post
Share on other sites
Thanks, that looks like its probably what I wanted. You know of any good docs on the STL? I''m having a hard time finding info about the 2nd template argument(traits) in the MSDN, and I''ll need to redefine it.

Share this post


Link to post
Share on other sites
quote:
Original post by Extrarius
Thanks, that looks like its probably what I wanted. You know of any good docs on the STL? I''m having a hard time finding info about the 2nd template argument(traits) in the MSDN, and I''ll need to redefine it.


Nicolai M Josuttis,
"The C++ Standard Library, a tutorial and reference"
ed. Addison-Wesley
ISBN 0-201--37926-0

is a must have. Honest.

Otherwise, you can make do with SGI''s STL reference.
See the links in my signature.


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites
quote:
Original post by Fruny
Nicolai M Josuttis,
"The C++ Standard Library, a tutorial and reference"
ed. Addison-Wesley
ISBN 0-201--37926-0

is a must have . Honest.




I''d be very careful with this book. It''s fine as a reference for what different functions and classes do, but some of his example code is not exception safe. Severely so in some cases (his stack and queue wrappers, for example).

Share this post


Link to post
Share on other sites
quote:
Original post by blizzard999
See also www.sgi.com and somewhere you find a great STL reference : useful!


Surprise! That''s where my signature link points!
Thanks for playing


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

Share this post


Link to post
Share on other sites