Standard C++ Library Class Reference
Equality operator. Returns true if x is the same as y.
template <class T, class Allocator>
bool operator< (const deque<T, Allocator>& x,
const deque<T, Allocator>& y);
Returns true if the elements contained in x are lexicographically less than the elements
contained in y.
template <class T, class Allocator>
void swap (deque<T, Allocator>& a, deque<T, Allocator>& b);
Efficiently swaps the contents of a and b.
Example
//
// deque.cpp
//
#include <deque>
#include <string>
deque<string, allocator> deck_of_cards;
deque<string, allocator> current_hand;
void initialize_cards(deque<string, allocator>& cards) {
cards.push_front("aceofspades");
cards.push_front("kingofspades");
cards.push_front("queenofspades");
cards.push_front("jackofspades");
cards.push_front("tenofspades");
// etc.
}
template <class It, class It2>
void print_current_hand(It start, It2 end)
{
while (start < end)
cout << *start++ << endl;
}
template <class It, class It2>
void deal_cards(It, It2 end) {
for (int i=0;i<5;i++) {
current_hand.insert(current_hand.begin(),*end);
deck_of_cards.erase(end++);
}
}
void play_poker() {
initialize_cards(deck_of_cards);
deal_cards(current_hand.begin(),deck_of_cards.begin());