Class: RejuicerSet
- Inherits:
-
Object
- Object
- RejuicerSet
- Defined in:
- ext/rejuicer_set/main.c
Instance Method Summary collapse
-
#add(value) ⇒ Object
(also: #<<)
add.
-
#clear ⇒ Object
cler.
-
#delete(value) ⇒ Object
delete.
-
#empty? ⇒ Boolean
empty?.
-
#initialize_copy(orig) ⇒ Object
initialize_copy.
-
#intersection(other) ⇒ Object
(also: #&)
intersection.
-
#size ⇒ Object
(also: #length)
size.
-
#to_a ⇒ Object
to_a.
-
#union(other) ⇒ Object
(also: #|)
union.
Instance Method Details
#add(value) ⇒ Object Also known as: <<
add
68 69 70 71 72 73 74 75 76 77 |
# File 'ext/rejuicer_set/main.c', line 68
static VALUE t_add(VALUE self, VALUE value)
{
root_node root;
unsigned int num;
Data_Get_Struct(self, struct _root_node, root);
add_num(root, NUM2UINT(value));
return self;
}
|
#clear ⇒ Object
cler
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'ext/rejuicer_set/main.c', line 179
static VALUE t_clear(VALUE self)
{
root_node root;
Data_Get_Struct(self, struct _root_node, root);
if (root->size) {
destroy_all_branches(root);
}
return self;
}
|
#delete(value) ⇒ Object
delete
82 83 84 85 86 87 88 89 90 91 |
# File 'ext/rejuicer_set/main.c', line 82
static VALUE t_delete(VALUE self, VALUE value)
{
root_node root;
unsigned int num;
Data_Get_Struct(self, struct _root_node, root);
delete_num(root, NUM2UINT(value));
return self;
}
|
#empty? ⇒ Boolean
empty?
163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'ext/rejuicer_set/main.c', line 163
static VALUE t_empty(VALUE self)
{
root_node root;
Data_Get_Struct(self, struct _root_node, root);
if (root->size == 0) {
return Qtrue;
} else {
return Qfalse;
}
}
|
#initialize_copy(orig) ⇒ Object
initialize_copy
54 55 56 57 58 59 60 61 62 63 |
# File 'ext/rejuicer_set/main.c', line 54
static VALUE t_initialize_copy(VALUE self, VALUE orig)
{
root_node root, orig_set;
Data_Get_Struct(self, struct _root_node, root);
Data_Get_Struct(orig, struct _root_node, orig_set);
copy_root_node(root, orig_set);
return self;
}
|
#intersection(other) ⇒ Object Also known as: &
intersection
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'ext/rejuicer_set/main.c', line 96
static VALUE t_intersection(VALUE self, VALUE other)
{
root_node set0, set1, ret_set;
VALUE ret;
ret = Data_Make_Struct(rb_cRejuicerSet, struct _root_node, NULL, destroy_all, ret_set);
init_root_node(ret_set);
Data_Get_Struct(self, struct _root_node, set0);
Data_Get_Struct(other, struct _root_node, set1);
intersection(ret_set, set0, set1);
return ret;
}
|
#size ⇒ Object Also known as: length
size
151 152 153 154 155 156 157 158 |
# File 'ext/rejuicer_set/main.c', line 151
static VALUE t_size(VALUE self)
{
root_node root;
Data_Get_Struct(self, struct _root_node, root);
return INT2NUM(root->size);
}
|
#to_a ⇒ Object
to_a
134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'ext/rejuicer_set/main.c', line 134
static VALUE t_to_a(VALUE self)
{
int i;
root_node root;
VALUE array;
Data_Get_Struct(self, struct _root_node, root);
array = rb_ary_new2(root->size);
to_array(root, array);
return array;
}
|
#union(other) ⇒ Object Also known as: |
union
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'ext/rejuicer_set/main.c', line 115
static VALUE t_union(VALUE self, VALUE other)
{
root_node set0, set1, ret_set;
VALUE ret;
ret = Data_Make_Struct(rb_cRejuicerSet, struct _root_node, NULL, destroy_all, ret_set);
init_root_node(ret_set);
Data_Get_Struct(self, struct _root_node, set0);
Data_Get_Struct(other, struct _root_node, set1);
join(ret_set, set0, set1);
return ret;
}
|