class Containers::CBst

  1. ext/containers/bst/bst.c
Parent: Containers

Methods

Public Class

  1. new

Public Instance

  1. delete
  2. each
  3. push
  4. size

Public Instance Aliases

[]= -> push

Public Class methods

new ()
[show source]
static VALUE bst_initialize(VALUE self) {
        return self;
}

Public Instance methods

delete (p1)
[show source]
static VALUE rb_bst_delete(VALUE self, VALUE key) {
        bst *tree = get_bst_from_self(self);
        bst_node *tobeDeleted = search_node(tree, tree->root, key);
        if(tobeDeleted) { 
                tree->size -= 1;
                bst_node *deletedNode = delete_node(&(tree->root),tobeDeleted);
                return deletedNode->value;
        }
        return Qnil;
}
each ()
[show source]
static VALUE rb_bst_each(VALUE self) {
        bst *tree = get_bst_from_self(self);
        bst_each(tree, &bst_each_helper, NULL);
        return self;
}
push (p1, p2)
[show source]
static VALUE rb_bst_push_value(VALUE self, VALUE key, VALUE value) {
        bst *tree = get_bst_from_self(self);
        insert_element(tree, &(tree->root), create_node(key,value));
        tree->size++;
        return self;
}
size ()
[show source]
static VALUE rb_bst_size(VALUE self) { 
        bst *tree;
        Data_Get_Struct(self,bst,tree);
        return INT2FIX(tree->size);
}