-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfreq.h
40 lines (27 loc) · 811 Bytes
/
freq.h
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
#ifndef FREQ_H__
#define FREQ_H__
/*
* Compute the frequency of some characters from a string with respect to a
* charset.
*/
#include <sys/types.h>
#include "charset.h"
struct freq {
const struct charset *charset;
float *freq;
};
/* Initialize a struct freq. */
void freq_init(struct freq *f, const struct charset *charset);
/* Deinitialize a struct freq. */
void freq_fini(struct freq *f);
/*
* Compute the frequency of the string str with repect to the charset given in
* the initialization, but only take one character every n characters of str.
*/
void freq_compute_stride(struct freq *f, const char *str, size_t n);
/*
* Compute the frequency of the string str with repect to the charset given in
* the initialization.
*/
void freq_compute(struct freq *f, const char *str);
#endif