Пример #1
0
Btree btree_delete(String key, Btree t)
{
  if (btree_isempty(t))
    return t;
  else if (strcmp(key, t->key) < 0){
    if (btree_isempty(t->left))
      return t;
    else{
      t->left = btree_delete(key, t->left);
      return t;
    }}
    else if (strcmp(key, t->key) > 0){
      if (btree_isempty(t->right))
	return t;
      else{
	t->right = btree_delete(key, t->right);
	return t;
      }}
    else if ((btree_isempty(t->right)) && (btree_isempty(t->left))){
      free(t->key);
      free(t->value);
      free(t);
	return btree_empty();
    }
    else if (btree_isempty(t->left)){
      Btree p = t->right;
      free(t->key);
      free(t->value);
      free(t);
	return p;
    }
    else if (btree_isempty(t->right)){
      Btree p = t->left;
      free(t->key);
      free(t->value);
      free(t);
	return p;
    }
      else{
	Btree p;
        p->key = min_key(t->right);
	p->value = min_val(t->right);
	p->right = deletemin(t->right);
	free(t->key);
	free(t->value);
	free(t);
	return p;
      }
}
 //! Returns the actual N-dimensional size of the sparse multi-array.
 inline coord_type all_actual_sizes() const
 { return max_key()-min_key(); }