Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Usage of the standard template tree library  class

Posted on 1997-08-05
1
Medium Priority
?
270 Views
Last Modified: 2010-04-10
I'm trying to use the standard template tree library class. The template contains the following classes:
template <class key, class value, class keyOfValue, class Compare>
For key and value I can probably use integer, but for the other two classes I'm confused.
I need an example on the usage of the tree template class or anything that would point me in the right direction.



0
Comment
Question by:merced
1 Comment
 
LVL 5

Accepted Solution

by:
yonat earned 800 total points
ID: 1166844
Yo must mean the map template, which is implemented in terms of
a binary tree. Here is how oyu use map with integer keys and
values:

map<int, int, less<int> > aMap;

In case you want to use the underlying tree class, note that it
is implementation dependent. In SGI STL it is rb_tree. The value,
key and Compare are the same as for map. The KeyOfValue is a functor that converts a value to a key.

In general, you shoud not use rb_tree directly. Instead use map.


0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question