hce-node application  1.4.3
HCE Hierarchical Cluster Engine node application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cf_average.h
Go to the documentation of this file.
1 /*
2  * A general purpose vector
3  * Uses locks, so only moderately fast
4  * If you need to deal with sparse data, really sparse data,
5  * use a hash table. This assumes that packed data is a good idea.
6  * Does the fairly trivial realloc thing for extension,
7  * so
8  * And you can keep adding cool things to it
9  * Copywrite 2008 Brian Bulkowski
10  * All rights reserved
11  */
12 
13 #pragma once
14 
15 #include <stdint.h>
16 
18 
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 
25 typedef struct cf_average_s {
26  int flags;
27  uint32_t n_points;
28  uint64_t points_sum;
29 } cf_average;
30 
31 
32 
33 cf_average *cf_average_create(uint32_t initial_size, uint32_t flags);
34 void cf_average_destroy( cf_average *avg);
35 void cf_average_clear(cf_average *avg);
36 int cf_average_add(cf_average *avgp, uint64_t value); // warning! this fails if too many samples
37 double cf_average_calculate(cf_average *avg, bool clear);
38 
39 // maybe it would be nice to have a floating point version?
40 
41 
42 
43 #ifdef __cplusplus
44 } // end extern "C"
45 #endif
46 
47 
48