Solved

# Stander Template Llibrary <algorithm>

Posted on 2004-04-06
240 Views
Hello

I’m looking to study up on my STL (stander template library)
I got the containers down and most of the container adaptors.

What I’m looking for is a website that as a example of all the algorithm.

Like
Find()
Find_if()
Generate()
Genereate_n()

0
Question by:funvill

LVL 4

Accepted Solution

PerryDK earned 50 total points
http://wwwasd.web.cern.ch/wwwasd/lhc++/RW/stdlibcr/classref.htm

This contains all the links you will need.  It will example codes for nearly all the stl functions.  For example if you click on the find function who's url is

http://wwwasd.web.cern.ch/wwwasd/lhc++/RW/stdlibcr/fin_7988.htm

it will have an example code with output as well for the find function such as

//
// find.cpp
//
#include <vector>
#include <algorithm>
int main()
{
typedef vector<int>::iterator iterator;
int d1[10] = {0,1,2,2,3,4,2,2,6,7};
// Set up a vector
vector<int> v1(d1,d1 + 10);
// Try find
iterator it1 = find(v1.begin(),v1.end(),3);
// it1 = v1.begin() + 4;
// Try find_if
iterator it2 =
find_if(v1.begin(),v1.end(),bind1st(equal_to<int>(),3));
// it2 = v1.begin() + 4
// it3 = v1.begin() +2
iterator it4 =
// v4 = v1.begin() + 2
// Output results
cout << *it1 << " " << *it2 << " " << *it3 << " "
<< *it4 << endl;
return 0;
}
Output : 3 3 2 2

0

LVL 2

Author Comment

perfect
thank you.
0

## Featured Post

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.