Class: Algorithms::Containers::CBst
- Inherits:
-
Object
- Object
- Algorithms::Containers::CBst
- Defined in:
- ext/containers/bst/bst.c
Instance Method Summary collapse
- #delete(key) ⇒ Object
- #each ⇒ Object
- #initialize ⇒ Object constructor
- #push(key, value) ⇒ Object (also: #[]=)
- #size ⇒ Object
Constructor Details
#initialize ⇒ Object
17 18 19 |
# File 'ext/containers/bst/bst.c', line 17 static VALUE bst_initialize(VALUE self) { return self; } |
Instance Method Details
#delete(key) ⇒ Object
215 216 217 218 219 220 221 222 223 224 |
# File 'ext/containers/bst/bst.c', line 215
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 ⇒ Object
209 210 211 212 213 |
# File 'ext/containers/bst/bst.c', line 209
static VALUE rb_bst_each(VALUE self) {
bst *tree = get_bst_from_self(self);
bst_each(tree, &bst_each_helper, NULL);
return self;
}
|
#push(key, value) ⇒ Object Also known as: []=
198 199 200 201 202 203 |
# File 'ext/containers/bst/bst.c', line 198
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 ⇒ Object
226 227 228 229 230 |
# File 'ext/containers/bst/bst.c', line 226
static VALUE rb_bst_size(VALUE self) {
bst *tree;
Data_Get_Struct(self,bst,tree);
return INT2FIX(tree->size);
}
|