-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspacesaver.hpp
More file actions
34 lines (28 loc) · 829 Bytes
/
spacesaver.hpp
File metadata and controls
34 lines (28 loc) · 829 Bytes
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
// Mark Fuge
// SpaceSaver Algorithm Implementation
#include <boost/bimap.hpp>
#include <string>
#include <boost/bimap/unordered_set_of.hpp>
#include <boost/bimap/list_of.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/bimap/support/lambda.hpp>
using namespace boost::bimaps;
typedef bimap
<
unordered_set_of< std::string >,
multiset_of< int,std::greater<int> > /*< `counter` is an integer that is initialized
in zero in the constructor >*/
> word_counter;
class SpaceSaver{
public:
SpaceSaver(); // Initializes the data structures
~SpaceSaver(); // Cleans up remaining data structures
void ClearAll(); // Clean Up Memory Structures
void initializeBimap();
void updateBimapWithWord(std::string word);
void printWordListByFreq();
private:
int max_pairs;
word_counter bimap;
int counter;
};