Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Usage of the standard template tree library  class

Posted on 1997-08-05
1
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

661 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