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

Started by
7 comments, last by Extrarius 20 years, 5 months ago
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]
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Advertisement
std::set

[ 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 ]
"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
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.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
The "C++ STL doc" in his sig is a great help.

"Sneftel is correct, if rather vulgar." --Flarelocke
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 ]
"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
I must have skipped his sig cuz its too small to read for me =-)
/me enlarges font, clicks, and shrinks it back
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
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).
See also www.sgi.com and somewhere you find a great STL reference : useful!
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 ]
"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

This topic is closed to new replies.

Advertisement