forked from HPI-Artificial-Intelligence-Teaching/24-pt2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bag_test.cpp
48 lines (42 loc) · 894 Bytes
/
bag_test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/******************************************************************************
*
* A generic bag or multiset, implemented using a singly linked list.
*
* Based on the source code from Robert Sedgewick and Kevin Wayne at https://algs4.cs.princeton.edu/
*
* % more ../data/tobe.txt
* to be or not to - be - - that - - - is
*
* % ./bag_test < ../data/tobe.txt
* size of bag = 14
* is
* -
* -
* -
* that
* -
* -
* be
* -
* to
* not
* or
* be
* to
*
******************************************************************************/
#include "bag.h"
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
Bag<string> bag;
string item;
while (cin >> item)
bag.add(item);
cout << "size of bag = " << bag.size() << endl;
for (auto& s : bag)
cout << s << endl;
return (0);
}