Exemplo n.º 1
0
 bool predecessor(const Key& k, Key& pre) {
   BSTNode* cur = find_rec(this->root_, k);
   if (cur == nullptr) return false;
   BSTNode* pre_node = predecessor(cur);
   if (pre_node != nullptr) pre = pre_node->key_;
   return pre_node != nullptr;
 }
Exemplo n.º 2
0
 bool successor(const Key& k, Key& suc) {
   BSTNode* cur = find_rec(this->root_, k);
   if (cur == nullptr) return false;
   BSTNode* suc_node = successor(cur);
   if (suc_node != nullptr) suc = suc_node->key_;
   return suc_node != nullptr;
 }
Exemplo n.º 3
0
Arquivo: mtree.c Projeto: taysom/tau
int delete_leaf (tree_s *tree, leaf_s *leaf, u32 key)
{
    rec_s	*r;
    FN;
    r = find_rec(leaf, key);
    if (r) {
        leaf->l_total += sizeof(rec_s) + r->r_size;
        memmove(r, r + 1,
                (char *)&leaf->l_rec[--leaf->l_num] - (char *)r);
        return 0;
    }
    eprintf("Key not found %llx\n", key);
    return qERR_NOT_FOUND;
}
Exemplo n.º 4
0
Arquivo: btree.c Projeto: taysom/tau
void delete_leaf (leaf_s *leaf, u64 key)
{
	rec_s	*r;
FN;
	r = find_rec(leaf, key);
	if (r) {
		leaf->l_total += sizeof(rec_s) + r->r_len;
		memmove(r, r + 1,
			(char *)&leaf->l_rec[--leaf->l_num] - (char *)r);
		bdirty(leaf);
		return;
	}
	printf("Key not found %llu\n", key);
	exit(2);
}
Exemplo n.º 5
0
ColMsg * ColMsg::find_rec(const QString & hr, ColMsgList & top)
{
  Q3PtrListIterator<ColMsg> it(top);
  int index;
  
  for (index = 0; it.current(); ++it, index += 1) {
    if (it.current()->hierarchical_rank == hr)
      return it.current();
    
    ColMsg * result = find_rec(hr, it.current()->msgs);
    
    if (result != 0)
      return result;
  }
  
  return 0;
}
Exemplo n.º 6
0
static void libdef_rec(BuildCtx *ctx, char *p, int arg)
{
    UNUSED(arg);
    if (ctx->mode == BUILD_recdef) {
        char *q;
        uint32_t n;
        for (; recffid+1 < ffid; recffid++)
            fprintf(ctx->fp, ",\n0");
        recffid = ffid;
        if (*p == '.') p = funcname;
        q = strchr(p, ' ');
        if (q) *q++ = '\0';
        n = find_rec(p);
        if (q)
            fprintf(ctx->fp, ",\n0x%02x00+(%s)", n, q);
        else
            fprintf(ctx->fp, ",\n0x%02x00", n);
    }
}
Exemplo n.º 7
0
 BSTNode* find_rec(BSTNode* cur, const Key& k) {
   if (cur == nullptr || cur->key_ == k) return cur;
   if (k < cur->key_) return find_rec(cur->left_, k);
   return find_rec(cur->right_, k);
 }
Exemplo n.º 8
0
 void remove(const Key& k) {
   BSTNode* cur = find_rec(this->root_, k);
   remove_rec(cur);
 }