All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
target/Linux-x86_64/include/citrusleaf/cf_average.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2008-2013 by Aerospike.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to
6  * deal in the Software without restriction, including without limitation the
7  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8  * sell copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20  * IN THE SOFTWARE.
21  *****************************************************************************/
22 #pragma once
23 
24 #include <stdint.h>
25 
26 #include <citrusleaf/cf_types.h>
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 /******************************************************************************
33  * TYPES
34  *****************************************************************************/
35 
36 struct cf_average_s {
37  int flags;
38  uint32_t n_points;
39  uint64_t points_sum;
40 };
41 
42 typedef struct cf_average_s cf_average;
43 
44 /******************************************************************************
45  * FUNCTIONS
46  *****************************************************************************/
47 
48 cf_average * cf_average_create(uint32_t initial_size, uint32_t flags);
49 void cf_average_destroy( cf_average * avg);
50 void cf_average_clear(cf_average * avg);
51 int cf_average_add(cf_average * avgp, uint64_t value); // warning! this fails if too many samples
52 double cf_average_calculate(cf_average * avg, bool clear);
53 
54 // maybe it would be nice to have a floating point version?
55 
56 /*****************************************************************************/
57 
58 #ifdef __cplusplus
59 } // end extern "C"
60 #endif
cf_average * cf_average_create(uint32_t initial_size, uint32_t flags)
double cf_average_calculate(cf_average *avg, bool clear)
void cf_average_destroy(cf_average *avg)
void cf_average_clear(cf_average *avg)
int cf_average_add(cf_average *avgp, uint64_t value)