parQHV
Compute HyperVolumes using threads
 All Data Structures Files Functions Variables Macros
counterHash.c
1 /*
2  *
3  * Copyright (c) Year(s), 2013, Luis M. S. Russo and Alexandre
4  * P. Francisco / KDBIO / INESC-ID, <qhv@kdbio.inesc-id.pt>
5  *
6  * Any published media that is related with to use of the distributed
7  * software, or derived software, must contain a reference to "Extending
8  * quick hypervolume. Luís M. S. Russo, Alexandre P. Francisco:
9  * J. Heuristics 22(3): 245-271 (2016)".
10  *
11  * Permission to use, copy, modify, and/or distribute this software for
12  * any purpose with or without fee is hereby granted, provided that the
13  * above copyright notice and this permission notice appear in all
14  * copies.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
17  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
19  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
21  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23  * PERFORMANCE OF THIS SOFTWARE.
24  *
25  */
26 
27 #include "counterHash.h"
28 #include "point.h"
29 
30 #if D < 20
31 
33 /*** global variables *************************************/
34 
35 /*** file scope macro definitions *************************/
36 
37 /*** file scope type declarations *************************/
38 
40 {
41  int* H;
42 };
43 
44 /*** file scope variables *********************************/
45 
46 /*** file scope functions declarations ********************/
47 
48 /*** public functions declarations ************************/
49 
50 /*** file scope functions *********************************/
51 
52 /* ------------------------------------------------------ */
53 
54 /*** public functions *************************************/
55 
57 {
58  counterHash this;
59 
60  this = (counterHash) calloc(1, sizeof(struct counterHash));
61  this->H = (int*) calloc(n, sizeof(int));
62 
63  return this;
64 }
65 
66 void CHfree(counterHash* this)
67 {
68  free((*this)->H);
69  free(*this);
70  *this = NULL;
71 }
72 
73 void CHinc(counterHash this, int i, int a)
74 {
75  this->H[i] += a;
76 }
77 
78 void CHzero(counterHash this, int i)
79 {
80  this->H[i] = 0;
81 }
82 
83 int CHget(counterHash this, int i)
84 {
85  return this->H[i];
86 }
87 
88 #else /* D < 20 */
89 #error TODO: Implement deamortized hash
91 
92 /*** global variables *************************************/
93 
94 /*** file scope macro definitions *************************/
95 
96 /*** file scope type declarations *************************/
97 
98 struct counterHash
99 {
100 
101 };
102 
103 /*** file scope variables *********************************/
104 
105 /*** file scope functions declarations ********************/
106 
107 /*** public functions declarations ************************/
108 
109 /*** file scope functions *********************************/
110 
111 /* ------------------------------------------------------ */
112 
113 /*** public functions *************************************/
114 
115 #endif /* D < 20 */
counterHash CHalloc(int n)
Definition: counterHash.c:56
void CHzero(counterHash this, int i)
Definition: counterHash.c:78
int CHget(counterHash this, int i)
Definition: counterHash.c:83
A hash for containing counter values.
void CHinc(counterHash this, int i, int a)
Definition: counterHash.c:73
Simple point interface. Contains simple point manipulation functions.
void CHfree(counterHash *this)
Definition: counterHash.c:66
Less than 1K use array of counters.
Definition: counterHash.c:39