-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taula.hh
90 lines (65 loc) · 2.15 KB
/
Taula.hh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/** @file Taula.hh
@brief Especificació de la classe Taula
*/
#ifndef TAULA_HH
#define TAULA_HH
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <utility>
using namespace std;
typedef unordered_map<string,int> MSI;
typedef pair<string,int> PSD;
typedef vector<PSD> VPSD;
/** @class Taula
@brief Representa una taula de freqüències de paraules
Conté un mapa de totes les paraules amb les seves aparicions i un vector ordenat amb les freqüències.
*/
class Taula
{
private:
// incluimos los campos de la clase para que se vea que los elementos privados
// no aparecen en la documentación si está así configurado el Doxyfile
//nombre de paraules total de la frase
MSI aparicions_string;
VPSD freq_string;
public:
//Constructoras
/** @brief Creadora per defecte.
S'executa automàticament al declarar una taula.
\pre <em>cert</em>
\post El resultat és una taula buida
*/
Taula();
//Modificadoras
/** @brief Modificadora del mapa
\pre cert, string s=S
\post Les aparicions de S guardades en el map han augmentat en 1,
o s'ha creat la primera aparició en cas de no existir
*/
void afegir_un(string s);
//Augmentar en 1 les aparicions de string en el map
/** @brief Modificadora del mapa i el vector
\pre <em>cert</em>
\post Si la taula contenia la string actual, s'han afegit les aparicions i freqüència de actual a seguent,
i s'ha eliminat actual de la taula. Si no, no fa res.
*/
void replace_strings(string actual, string seguent);
//Actualitza el mapa i el vector d'aparicions
/** @brief Modificadora del vector
\pre El mapa d'aparicions té tota la informació actualitzada
\post El vector està ordenat per freqüència i conté tota la informació del mapa
*/
void crear_vector();
//Crea un vector, ordenat per freqüències, que representa el mapa
//actual
//Escriptura
/** @brief Operació d'escriptura
\pre <em>cert</em>
\post Escriu el contingut del paràmetre implícit per la sortida estàndard
*/
void escriure_taula_freq();
//Mostra el contingut del vector de freqüències
};
#endif