Class: Roaring::Bitmap64
- Inherits:
-
Object
- Object
- Roaring::Bitmap64
- Extended by:
- Roaring::BitmapCommon::ClassMethods
- Includes:
- BitmapCommon
- Defined in:
- lib/roaring.rb,
ext/roaring/bitmap64.c
Constant Summary collapse
- MIN =
0- MAX =
(2**64) - 1
- RANGE =
MIN..MAX
Class Method Summary collapse
-
.[](*args) ⇒ Object
extended
from Roaring::BitmapCommon::ClassMethods
Convenience method for building a bitmap.
- ._load(args) ⇒ Object extended from Roaring::BitmapCommon::ClassMethods
- .deserialize(str) ⇒ Object
Instance Method Summary collapse
- #<(other) ⇒ Object (also: #proper_subset?)
- #<=(other) ⇒ Object (also: #subset?)
-
#<=>(other) ⇒ Integer
included
from BitmapCommon
Returns 0 if the bitmaps are equal, -1 / +1 if the set is a subset / superset of the given set, or nil if they both have unique elements.
- #==(other) ⇒ Object (also: #eql?)
- #[](rankv) ⇒ Object
- #_dump(level) ⇒ Object included from BitmapCommon
- #add(val) ⇒ Object (also: #<<)
- #add?(val) ⇒ Boolean
- #add_range(min, max) ⇒ Object included from BitmapCommon
- #add_range_closed(minv, maxv) ⇒ Object
- #and(other) ⇒ Object (also: #&, #intersection)
- #and!(other) ⇒ Object
- #andnot(other) ⇒ Object (also: #-, #difference)
- #andnot!(other) ⇒ Object
- #cardinality ⇒ Object (also: #size, #length, #count)
- #clear ⇒ Object
- #disjoint?(other) ⇒ Boolean included from BitmapCommon
- #each ⇒ Object
- #empty? ⇒ Boolean
- #hash ⇒ Object included from BitmapCommon
- #include?(val) ⇒ Boolean (also: #===)
- #initialize(enum = nil) ⇒ Object included from BitmapCommon
- #initialize_copy(other) ⇒ Object included from BitmapCommon
-
#inspect ⇒ String
included
from BitmapCommon
A programmer-readable representation of the bitmap.
- #intersect?(other) ⇒ Boolean
- #max ⇒ Object (also: #last)
- #min ⇒ Object (also: #first)
- #or(other) ⇒ Object (also: #|, #+, #union)
- #or!(other) ⇒ Object
-
#proper_superset?(other) ⇒ Boolean
(also: #>)
included
from BitmapCommon
Check if
selfis a strict superset ofother. - #remove(val) ⇒ Object (also: #delete)
- #remove?(val) ⇒ Boolean (also: #delete?)
- #replace(other) ⇒ Object
- #run_optimize ⇒ Object
- #serialize ⇒ Object
- #statistics ⇒ Object
-
#superset?(other) ⇒ Boolean
(also: #>=)
included
from BitmapCommon
Check if
selfis a superset ofother. - #to_set ⇒ Object included from BitmapCommon
- #xor(other) ⇒ Object (also: #^)
- #xor!(other) ⇒ Object
Class Method Details
.[](*args) ⇒ Object Originally defined in module Roaring::BitmapCommon::ClassMethods
Convenience method for building a bitmap
._load(args) ⇒ Object Originally defined in module Roaring::BitmapCommon::ClassMethods
.deserialize(str) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'ext/roaring/bitmap64.c', line 209
static VALUE rb_roaring64_deserialize(VALUE self, VALUE str)
{
StringValue(str);
roaring64_bitmap_t *bitmap = roaring64_bitmap_portable_deserialize_safe(RSTRING_PTR(str), RSTRING_LEN(str));
RB_GC_GUARD(str);
if (!bitmap) {
rb_raise(rb_eArgError, "invalid Roaring::Bitmap64 serialization");
}
return TypedData_Wrap_Struct(cRoaringBitmap64, &roaring64_type, bitmap);
}
|
Instance Method Details
#<(other) ⇒ Object Also known as: proper_subset?
329 330 331 332 |
# File 'ext/roaring/bitmap64.c', line 329
static VALUE rb_roaring64_lt(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_bool(self, other, roaring64_bitmap_is_strict_subset);
}
|
#<=(other) ⇒ Object Also known as: subset?
334 335 336 337 |
# File 'ext/roaring/bitmap64.c', line 334
static VALUE rb_roaring64_lte(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_bool(self, other, roaring64_bitmap_is_subset);
}
|
#<=>(other) ⇒ Integer Originally defined in module BitmapCommon
Returns 0 if the bitmaps are equal, -1 / +1 if the set is a subset / superset of the given set, or nil if they both have unique elements.
#==(other) ⇒ Object Also known as: eql?
324 325 326 327 |
# File 'ext/roaring/bitmap64.c', line 324
static VALUE rb_roaring64_eq(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_bool(self, other, roaring64_bitmap_equals);
}
|
#[](rankv) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'ext/roaring/bitmap64.c', line 151
static VALUE rb_roaring64_aref(VALUE self, VALUE rankv)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t rank = NUM2UINT64(rankv);
uint64_t val;
if (roaring64_bitmap_select(data, rank, &val)) {
return ULL2NUM(val);
} else {
return Qnil;
}
return self;
}
|
#_dump(level) ⇒ Object Originally defined in module BitmapCommon
#add(val) ⇒ Object Also known as: <<
72 73 74 75 76 77 78 79 |
# File 'ext/roaring/bitmap64.c', line 72
static VALUE rb_roaring64_add(VALUE self, VALUE val)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t num = NUM2UINT64(val);
roaring64_bitmap_add(data, num);
return self;
}
|
#add?(val) ⇒ Boolean
81 82 83 84 85 86 87 |
# File 'ext/roaring/bitmap64.c', line 81
static VALUE rb_roaring64_add_p(VALUE self, VALUE val)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t num = NUM2UINT64(val);
return roaring64_bitmap_add_checked(data, num) ? self : Qnil;
}
|
#add_range(min, max) ⇒ Object Originally defined in module BitmapCommon
#add_range_closed(minv, maxv) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'ext/roaring/bitmap64.c', line 89
static VALUE rb_roaring64_add_range_closed(VALUE self, VALUE minv, VALUE maxv)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t min = NUM2UINT64(minv);
uint64_t max = NUM2UINT64(maxv);
roaring64_bitmap_add_range_closed(data, min, max);
return self;
}
|
#and(other) ⇒ Object Also known as: &, intersection
304 305 306 307 |
# File 'ext/roaring/bitmap64.c', line 304
static VALUE rb_roaring64_and(VALUE self, VALUE other)
{
return rb_roaring64_binary_op(self, other, roaring64_bitmap_and);
}
|
#and!(other) ⇒ Object
284 285 286 287 |
# File 'ext/roaring/bitmap64.c', line 284
static VALUE rb_roaring64_and_inplace(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_inplace(self, other, roaring64_bitmap_and_inplace);
}
|
#andnot(other) ⇒ Object Also known as: -, difference
319 320 321 322 |
# File 'ext/roaring/bitmap64.c', line 319
static VALUE rb_roaring64_andnot(VALUE self, VALUE other)
{
return rb_roaring64_binary_op(self, other, roaring64_bitmap_andnot);
}
|
#andnot!(other) ⇒ Object
299 300 301 302 |
# File 'ext/roaring/bitmap64.c', line 299
static VALUE rb_roaring64_andnot_inplace(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_inplace(self, other, roaring64_bitmap_andnot_inplace);
}
|
#cardinality ⇒ Object Also known as: size, length, count
65 66 67 68 69 70 |
# File 'ext/roaring/bitmap64.c', line 65
static VALUE rb_roaring64_cardinality(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t cardinality = roaring64_bitmap_get_cardinality(data);
return ULONG2NUM(cardinality);
}
|
#clear ⇒ Object
132 133 134 135 136 137 |
# File 'ext/roaring/bitmap64.c', line 132
static VALUE rb_roaring64_clear(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
roaring64_bitmap_clear(data);
return self;
}
|
#disjoint?(other) ⇒ Boolean Originally defined in module BitmapCommon
#each ⇒ Object
144 145 146 147 148 149 |
# File 'ext/roaring/bitmap64.c', line 144
static VALUE rb_roaring64_each(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
roaring64_bitmap_iterate(data, rb_roaring64_each_i, NULL);
return self;
}
|
#empty? ⇒ Boolean
126 127 128 129 130 |
# File 'ext/roaring/bitmap64.c', line 126
static VALUE rb_roaring64_empty_p(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
return RBOOL(roaring64_bitmap_is_empty(data));
}
|
#hash ⇒ Object Originally defined in module BitmapCommon
#include?(val) ⇒ Boolean Also known as: ===
118 119 120 121 122 123 124 |
# File 'ext/roaring/bitmap64.c', line 118
static VALUE rb_roaring64_include_p(VALUE self, VALUE val)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t num = NUM2UINT64(val);
return RBOOL(roaring64_bitmap_contains(data, num));
}
|
#initialize(enum = nil) ⇒ Object Originally defined in module BitmapCommon
#initialize_copy(other) ⇒ Object Originally defined in module BitmapCommon
#inspect ⇒ String Originally defined in module BitmapCommon
Returns a programmer-readable representation of the bitmap.
#intersect?(other) ⇒ Boolean
339 340 341 342 |
# File 'ext/roaring/bitmap64.c', line 339
static VALUE rb_roaring64_intersect_p(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_bool(self, other, roaring64_bitmap_intersect);
}
|
#max ⇒ Object Also known as: last
178 179 180 181 182 183 184 185 186 187 188 |
# File 'ext/roaring/bitmap64.c', line 178
static VALUE rb_roaring64_max(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
if (roaring64_bitmap_is_empty(data)) {
return Qnil;
} else {
uint64_t val = roaring64_bitmap_maximum(data);
return ULL2NUM(val);
}
}
|
#min ⇒ Object Also known as: first
166 167 168 169 170 171 172 173 174 175 176 |
# File 'ext/roaring/bitmap64.c', line 166
static VALUE rb_roaring64_min(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
if (roaring64_bitmap_is_empty(data)) {
return Qnil;
} else {
uint64_t val = roaring64_bitmap_minimum(data);
return ULL2NUM(val);
}
}
|
#or(other) ⇒ Object Also known as: |, +, union
309 310 311 312 |
# File 'ext/roaring/bitmap64.c', line 309
static VALUE rb_roaring64_or(VALUE self, VALUE other)
{
return rb_roaring64_binary_op(self, other, roaring64_bitmap_or);
}
|
#or!(other) ⇒ Object
289 290 291 292 |
# File 'ext/roaring/bitmap64.c', line 289
static VALUE rb_roaring64_or_inplace(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_inplace(self, other, roaring64_bitmap_or_inplace);
}
|
#proper_superset?(other) ⇒ Boolean Also known as: > Originally defined in module BitmapCommon
Check if self is a strict superset of other. A strict superset requires that self contain all of other's elemtents, but that they aren't exactly equal.
#remove(val) ⇒ Object Also known as: delete
101 102 103 104 105 106 107 108 |
# File 'ext/roaring/bitmap64.c', line 101
static VALUE rb_roaring64_remove(VALUE self, VALUE val)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t num = NUM2UINT64(val);
roaring64_bitmap_remove(data, num);
return self;
}
|
#remove?(val) ⇒ Boolean Also known as: delete?
110 111 112 113 114 115 116 |
# File 'ext/roaring/bitmap64.c', line 110
static VALUE rb_roaring64_remove_p(VALUE self, VALUE val)
{
roaring64_bitmap_t *data = get_bitmap(self);
uint64_t num = NUM2UINT64(val);
return roaring64_bitmap_remove_checked(data, num) ? self : Qnil;
}
|
#replace(other) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'ext/roaring/bitmap64.c', line 52
static VALUE rb_roaring64_replace(VALUE self, VALUE other) {
roaring64_bitmap_t *self_data = get_bitmap(self);
roaring64_bitmap_t *other_data = get_bitmap(other);
// FIXME: Very likely a newer version of CRoaring will have
//roaring64_bitmap_overwrite(self_data, other_data);
roaring64_bitmap_clear(self_data);
roaring64_bitmap_or_inplace(self_data, other_data);
return self;
}
|
#run_optimize ⇒ Object
190 191 192 193 194 |
# File 'ext/roaring/bitmap64.c', line 190
static VALUE rb_roaring64_run_optimize(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
return RBOOL(roaring64_bitmap_run_optimize(data));
}
|
#serialize ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'ext/roaring/bitmap64.c', line 196
static VALUE rb_roaring64_serialize(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
size_t size = roaring64_bitmap_portable_size_in_bytes(data);
VALUE str = rb_str_buf_new(size);
size_t written = roaring64_bitmap_portable_serialize(data, RSTRING_PTR(str));
rb_str_set_len(str, written);
return str;
}
|
#statistics ⇒ Object
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'ext/roaring/bitmap64.c', line 223
static VALUE rb_roaring64_statistics(VALUE self)
{
roaring64_bitmap_t *data = get_bitmap(self);
roaring64_statistics_t stat;
roaring64_bitmap_statistics(data, &stat);
VALUE ret = rb_hash_new();
#define ADD_STAT(name) \
rb_hash_aset(ret, rb_id2sym(rb_intern(#name)), ULL2NUM(stat.name))
ADD_STAT(n_containers);
ADD_STAT(n_array_containers);
ADD_STAT(n_run_containers);
ADD_STAT(n_bitset_containers);
ADD_STAT(n_values_array_containers);
ADD_STAT(n_values_run_containers);
ADD_STAT(n_values_bitset_containers);
ADD_STAT(n_bytes_array_containers);
ADD_STAT(n_bytes_run_containers);
ADD_STAT(n_bytes_bitset_containers);
ADD_STAT(max_value);
ADD_STAT(min_value);
// ADD_STAT(sum_value); // deprecated, skipped
ADD_STAT(cardinality);
#undef ADD_STAT
return ret;
}
|
#superset?(other) ⇒ Boolean Also known as: >= Originally defined in module BitmapCommon
Check if self is a superset of other. A superset requires that self contain all of other's elemtents. They may be equal.
#to_set ⇒ Object Originally defined in module BitmapCommon
#xor(other) ⇒ Object Also known as: ^
314 315 316 317 |
# File 'ext/roaring/bitmap64.c', line 314
static VALUE rb_roaring64_xor(VALUE self, VALUE other)
{
return rb_roaring64_binary_op(self, other, roaring64_bitmap_xor);
}
|
#xor!(other) ⇒ Object
294 295 296 297 |
# File 'ext/roaring/bitmap64.c', line 294
static VALUE rb_roaring64_xor_inplace(VALUE self, VALUE other)
{
return rb_roaring64_binary_op_inplace(self, other, roaring64_bitmap_xor_inplace);
}
|