示例#1
0
 void push_back(const group_key_type &key, const ValueType &value)
 {
   map_iterator map_it;
   if(key.first == back_ungrouped_slots)
   {// optimization
     map_it = _group_map.end();
   }else
   {
     map_it = _group_map.upper_bound(key);
   }
   m_insert(map_it, key, value);
 }
示例#2
0
 void push_front(const group_key_type &key, const ValueType &value)
 {
   map_iterator map_it;
   if(key.first == front_ungrouped_slots)
   {// optimization
     map_it = _group_map.begin();
   }else
   {
     map_it = _group_map.lower_bound(key);
   }
   m_insert(map_it, key, value);
 }
int m_insert(struct KD_TREE *tree, struct Node **u, int k, struct Point *x, int dep) {
	if (*u == NULL) {
		(*u) = newNode(tree), (*u)->pid = *x;
		tree->data[tree->size++] = *x;
		return dep <= 0;
	}
	(*u)->size++;
	int t = 0;
	if (x->d[k] < (*u)->pid.d[k])
		t = m_insert(tree, &(*u)->lson, (k+1)%tree->kD, x, dep-1);
	else
		t = m_insert(tree, &(*u)->rson, (k+1)%tree->kD, x, dep-1);
	if (t && !isbad(*u))
		return 1;
	if (t) {
		flatten_size = 0;
		flatten(tree, *u);
		*u = build(tree, k, 0, (*u)->size-1);
	}
	return 0;
}
void s_insert(struct KD_TREE *tree, struct Point x) {
	m_insert(tree, &tree->root, 0, &x, log2int(tree->size) / LOG_ALPHA);
}