35 #include "divisionStruct.c"
52 static sureInline(
int) popcount(
unsigned int i);
62 static sureInline(
int) popcount(
unsigned int x)
64 unsigned int m1 = 0x55555555;
65 unsigned int m2 = 0x33333333;
66 unsigned int m4 = 0x0f0f0f0f;
68 x = (x & m2) + ((x >> 2) & m2);
69 x = (x + (x >> 4)) & m4;
71 return (x + (x >> 16)) & 0x3f;
88 hoList[i] = newArrayListDef();
89 piList[i] = newArrayListDef();
105 freeArrayList(&(hoList[i]));
106 freeArrayList(&(piList[i]));
114 void push(
int idx,
int tp,
struct spData * sd)
124 pushAL(hoList[i], tp);
125 pushAL(piList[i], idx);
126 CHinc(counters, tp, -1);
146 hypocts = newArrayList(1<<
D);
147 pPositions = newArrayListDef();
152 d->
points = (
int*) calloc(piAL,
sizeof(
int));
162 while(j < size(hoList[i]))
164 if(
CHget(counters,
get(hoList[i])[j]) < 0)
167 pushAL(pPositions, tc);
168 tc -=
CHget(counters,
get(hoList[i])[j]);
170 pushAL(hypocts,
get(hoList[i])[j]);
171 CHinc(counters,
get(hoList[i])[j], tc);
175 pushAL(pPositions, tc);
181 d->
points = (
int*) realloc(d->
points, piAL*
sizeof(
int));
186 while(j < size(piList[i]))
188 jj =
CHget(counters,
get(hoList[i])[j]);
189 d->
points[jj] =
get(piList[i])[j];
190 CHinc(counters,
get(hoList[i])[j], 1);
196 j =
get(pPositions)[jj];
200 get(pPositions)[jj] = limit;
202 while(j <
get(pPositions)[jj+1])
216 get(pPositions)[jj] = limit;
235 jj =
get(pPositions)[k];
238 j = dominant(tPS, &(d->
points[jj]),
239 get(pPositions)[k+1] - jj,
259 pushAL(pPositions, limit);
266 while(j < size(hoList[i]))
268 CHzero(counters,
get(hoList[i])[j]);
278 d->
hypocts = splitAL(&hypocts);
280 d->
points = (
int*) realloc(d->
points, limit*
sizeof(
int));
counterHash CHalloc(int n)
void CHzero(counterHash this, int i)
int CHget(counterHash this, int i)
A hash for containing counter values.
#define D
D is the number of dimensions.
division newDivision(point *PS, point *o, point *p, struct spData *sd)
void CHinc(counterHash this, int i, int a)
This header implements an arrayList for integers.
This returns iterators for diferent type. WARNING, these objects are singleton, so new overwrites exi...
Simple point interface. Contains simple point manipulation functions.
This struct is public because of splitter. Do not use direct access.
void initSplitter(struct spData *sd)
void push(int idx, int tp, struct spData *sd)
A splitter for storing classified points. The splitter is an array that grows dinamically, when all points are inserted they are separeted into classes by sorting. Preferably count sort or hased count sort.
int member(int i, struct unionData *ud)
Structure for uniting two sets, without repetition.
Point is an array of coordinates, in a struct for simple and fast copy.
void CHfree(counterHash *this)
Less than 1K use array of counters.
void finishUnion(struct unionData *ud)
void resetUnion(struct unionData *ud)
void insertUnion(int i, struct unionData *ud)
void destroySplitter(struct spData *sd)