5 * Created by Victor Grishchenko on 3/28/09.
6 * Copyright 2009 Delft Technical University. All rights reserved.
22 bool join(uint32_t half) {
23 uint32_t cellno = bits[half]>>(half&1?16:0);
25 if (deep(left) || deep(right)) // some half is deep
27 uint8_t b1=JOIN[cell&0xf],
28 b2=JOIN[(cell>>8)&0xf],
29 b3=JOIN[(cell>>16)&0xf],
31 if (b1==0xff || b2==0xff || b3==0xff || b4==0xff)
33 bits[half] = b1 | (b2<<4) | (b3<<8) | (b4<<12) ;
34 (*parentdeepcell) ^= 1<<(halfno&32);
35 (*childdeepcell) &= 0xffff>>1; // clean the full bit
38 bool split(uint32_t half) {
41 uint32_t cell = alloc_cell(), left=cell<<1, right=left+1;
42 bits[half|0xf] |= 1<<(half&0xf);
43 bits[left] = SPLIT[bits[half]>>8];
44 bits[right] = SPLIT[bits[half&0xff]];
49 uint32_t alloc_cell () {
51 for(int block=alloc_block; bits[block]&(1<<32); block+=32);
52 for(int off=0; bits[block+off]==0 && off<31; off++);
56 bits = realloc(bits,block*2);
79 uint16_t& operator* ();
81 friend class iterator;
83 bool get (uint64_t bin);
85 void set (uint64_t bin);
87 bin64_t find (bin64_t range, int layer);
89 // TODO: bitwise operators