Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
deque.cpp
Go to the documentation of this file.
1
29#include <deque>
30#include <iostream>
31#include <string>
32
33#include <examples.h>
34
35typedef std::deque<std::string, std::allocator<std::string> > Deque;
36
39
40
42{
43 cards.push_front ("ace of spades");
44 cards.push_front ("king of spades");
45 cards.push_front ("queen of spades");
46 cards.push_front ("jack of spades");
47 cards.push_front ("ten of spades");
48 //
49 // etc.
50 //
51}
52
53
54template <class It, class It2>
55void print_current_hand (It start, It2 end)
56{
57 while (start < end)
58 std::cout << *start++ << std::endl;
59}
60
61
62template <class It, class It2>
63void deal_cards (It, It2 end)
64{
65 for (int i = 0; i < 5; i++) {
66 current_hand.insert (current_hand.begin (), *end);
67 deck_of_cards.erase (end++);
68 }
69}
70
71
73{
75 deal_cards (current_hand.begin (), deck_of_cards.begin ());
76}
77
78
79int main ()
80{
81 play_poker ();
82
84
85 return 0;
86}
#define i
Definition 17.names.cpp:126
#define start
Definition 17.names.cpp:547
const int end
void play_poker()
Definition deque.cpp:72
std::deque< std::string, std::allocator< std::string > > Deque
Definition deque.cpp:35
Deque current_hand
Definition deque.cpp:38
Deque deck_of_cards
Definition deque.cpp:37
void print_current_hand(It start, It2 end)
Definition deque.cpp:55
void deal_cards(It, It2 end)
Definition deque.cpp:63
void initialize_cards(Deque &cards)
Definition deque.cpp:41
int main()
Definition deque.cpp:79