Solved

Usage of the standard template tree library  class

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now