Class: JudySet
- Inherits:
-
Object
- Object
- JudySet
- Defined in:
- ext/judy_set.c
Class Method Summary collapse
Instance Method Summary collapse
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
- #add(index) ⇒ Object
- #by_count(num) ⇒ Object
- #clear ⇒ Object
-
#delete(index) ⇒ Object
NULL means no marking.
- #do_get(index) ⇒ Object
- #do_set(index, value) ⇒ Object
- #each ⇒ Object
- #each_index ⇒ Object
- #first_index ⇒ Object
- #get(index) ⇒ Object
- #last_index ⇒ Object
- #length ⇒ Object
- #mem_used ⇒ Object
- #next_index(index) ⇒ Object
- #set(index, value) ⇒ Object
- #sum ⇒ Object
-
#unset(index) ⇒ Object
NULL means no marking.
Class Method Details
.new ⇒ Object
23 24 25 26 27 |
# File 'ext/judy_set.c', line 23 VALUE ruby_JudySet_allocate(VALUE self) { tree_object* set = malloc( sizeof(tree_object) ) ; set->judy = NULL; return Data_Wrap_Struct(self, NULL, gc_free_set, set); // NULL means no marking } |
Instance Method Details
#[](index) ⇒ Object
54 55 56 57 58 59 60 |
# File 'ext/judy_set.c', line 54 VALUE ruby_JudySet_get(VALUE self , VALUE index) { JudySet *p_set; if( index == Qnil ) return Qnil ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_has(p_set , index) ? Qtrue : Qfalse ; } |
#[]=(index, value) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'ext/judy_set.c', line 37 VALUE ruby_JudySet_set(VALUE self , VALUE index , VALUE value ) { JudySet *p_set; if( index == Qnil ) return Qnil ; if( value == Qnil || value == Qfalse ) return ruby_JudySet_delete(self , index) ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_set(p_set , index); } |
#add(index) ⇒ Object
46 47 48 49 50 51 52 |
# File 'ext/judy_set.c', line 46 VALUE ruby_JudySet_add(VALUE self , VALUE index ) { JudySet *p_set; if( index == Qnil ) return Qnil ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_set(p_set , index); } |
#by_count(num) ⇒ Object
67 68 69 70 71 |
# File 'ext/judy_set.c', line 67 VALUE ruby_JudySet_by_count(VALUE self, VALUE num) { JudySet *p_set = Get_Set(self) ; check_index_basic(num); return judy_set_at_count(p_set, num ) ; } |
#clear ⇒ Object
94 95 96 97 98 99 |
# File 'ext/judy_set.c', line 94 VALUE ruby_JudySet_clear(VALUE self) { JudySet *p_set = Get_Set(self) ; VALUE len = ruby_JudySet_length(self) ; judy_set_clear(p_set); return len; } |
#delete(index) ⇒ Object
NULL means no marking
29 30 31 32 33 34 35 |
# File 'ext/judy_set.c', line 29 VALUE ruby_JudySet_delete(VALUE self , VALUE index) { JudySet *p_set; if( index == Qnil ) return Qnil ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_delete(p_set , index) ; } |
#do_get(index) ⇒ Object
54 55 56 57 58 59 60 |
# File 'ext/judy_set.c', line 54 VALUE ruby_JudySet_get(VALUE self , VALUE index) { JudySet *p_set; if( index == Qnil ) return Qnil ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_has(p_set , index) ? Qtrue : Qfalse ; } |
#do_set(index, value) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'ext/judy_set.c', line 37 VALUE ruby_JudySet_set(VALUE self , VALUE index , VALUE value ) { JudySet *p_set; if( index == Qnil ) return Qnil ; if( value == Qnil || value == Qfalse ) return ruby_JudySet_delete(self , index) ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_set(p_set , index); } |
#each ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'ext/judy_set.c', line 101 VALUE ruby_JudySet_each(VALUE self) { JudySet *p_set = Get_Set(self) ; VALUE index = judy_set_first_index(p_set); while(index != Qfalse ){ rb_yield(index); index = judy_set_next_index(p_set, index); } return self; } |
#each_index ⇒ Object
101 102 103 104 105 106 107 108 109 |
# File 'ext/judy_set.c', line 101 VALUE ruby_JudySet_each(VALUE self) { JudySet *p_set = Get_Set(self) ; VALUE index = judy_set_first_index(p_set); while(index != Qfalse ){ rb_yield(index); index = judy_set_next_index(p_set, index); } return self; } |
#first_index ⇒ Object
78 79 80 81 |
# File 'ext/judy_set.c', line 78 VALUE ruby_JudySet_first_index(VALUE self) { JudySet *p_set = Get_Set(self) ; return judy_set_first_index(p_set); } |
#get(index) ⇒ Object
54 55 56 57 58 59 60 |
# File 'ext/judy_set.c', line 54 VALUE ruby_JudySet_get(VALUE self , VALUE index) { JudySet *p_set; if( index == Qnil ) return Qnil ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_has(p_set , index) ? Qtrue : Qfalse ; } |
#last_index ⇒ Object
89 90 91 92 |
# File 'ext/judy_set.c', line 89 VALUE ruby_JudySet_last_index(VALUE self) { JudySet *p_set = Get_Set(self) ; return judy_set_last_index(p_set); } |
#length ⇒ Object
62 63 64 65 |
# File 'ext/judy_set.c', line 62 VALUE ruby_JudySet_length(VALUE self) { JudySet *p_set = Get_Set(self) ; return judy_set_length(p_set); } |
#mem_used ⇒ Object
73 74 75 76 |
# File 'ext/judy_set.c', line 73 VALUE ruby_JudySet_mem_used(VALUE self) { JudySet *p_set = Get_Set(self) ; return judy_set_mem(p_set); } |
#next_index(index) ⇒ Object
83 84 85 86 87 |
# File 'ext/judy_set.c', line 83 VALUE ruby_JudySet_next_index(VALUE self, VALUE index) { JudySet *p_set = Get_Set(self) ; check_index_basic(index); return judy_set_next_index(p_set, index); } |
#set(index, value) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'ext/judy_set.c', line 37 VALUE ruby_JudySet_set(VALUE self , VALUE index , VALUE value ) { JudySet *p_set; if( index == Qnil ) return Qnil ; if( value == Qnil || value == Qfalse ) return ruby_JudySet_delete(self , index) ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_set(p_set , index); } |
#sum ⇒ Object
111 112 113 114 115 116 117 118 119 120 |
# File 'ext/judy_set.c', line 111 VALUE ruby_JudySet_sum(VALUE self ) { long int ret = 0; JudySet *p_set = Get_Set(self) ; VALUE index = judy_set_first_index(p_set); while(index != Qfalse ){ ret += NUM2LONG(index) ; index = judy_set_next_index(p_set, index); } return LONG2NUM(ret); } |
#unset(index) ⇒ Object
NULL means no marking
29 30 31 32 33 34 35 |
# File 'ext/judy_set.c', line 29 VALUE ruby_JudySet_delete(VALUE self , VALUE index) { JudySet *p_set; if( index == Qnil ) return Qnil ; p_set = Get_Set(self) ; check_index_basic(index); return judy_set_delete(p_set , index) ; } |