Solved

Usage of the standard template tree library  class

Posted on 1997-08-05
1
247 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 200 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

820 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