Solved

Usage of the standard template tree library  class

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

626 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