Checking if One Container Is Less Than or Greater Than Another : transform « deque « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » deque » transform 
22.12.2.Checking if One Container Is Less Than or Greater Than Another
#include <algorithm>
#include <deque>
#include <vector>
#include <iostream>

using namespace std;

template <class T>
void print(T& c){
   fortypename T::iterator i = c.begin(); i != c.end(); i++ ){
      std::cout << *i << endl;
   }
}

int main( )
{
   const int data1[] 200250250100500500400 };
   const int data2[] 200200300500400400 };

   // create and initialize vectors to hold the debts
   vector<int> debts1data1,data1 + sizeofdata1 / sizeofdata1[0] ) );
   vector<int> debts2data2,data2 + sizeofdata2 / sizeofdata2[0] ) );

   // sort into descending order
   sortdebts1.begin(), debts1.end(), greater<int>() );
   sortdebts2.begin(), debts2.end(), greater<int>() );

   // display debts
   printdebts1 );
   printdebts2 );

   ifdebts1 > debts2 )
      cout << "\nCollect from Group 1 first";
   else
      cout << "\nCollect from Group 2 first";

   // store one group of debts in a different container
   deque<int> debts2_dequedebts2.begin(), debts2.end() );

   // compare the vector to the deque
   iflexicographical_comparedebts2_deque.begin(),
      debts2_deque.end(), debts1.begin(), debts1.end() ) )
      cout << "\nCollect from Group 1 in vector first";
   else
      cout << "\nCollect from Group 2 in deque first";
}
22.12.transform
22.12.1.Transform deque with boolean function
22.12.2.Checking if One Container Is Less Than or Greater Than Another
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.