roaring 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Roaring
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/roaring.rb CHANGED
@@ -15,10 +15,18 @@ module Roaring
15
15
  alias count cardinality
16
16
 
17
17
  alias + |
18
+ alias union |
19
+ alias intersection &
20
+ alias difference -
21
+
22
+ alias delete remove
23
+ alias delete? remove?
18
24
 
19
25
  alias first min
20
26
  alias last max
21
27
 
28
+ alias === include?
29
+
22
30
  def initialize(enum = nil)
23
31
  return unless enum
24
32
 
@@ -29,6 +37,17 @@ module Roaring
29
37
  end
30
38
  end
31
39
 
40
+ def hash
41
+ to_a.hash
42
+ end
43
+
44
+ alias eql? ==
45
+
46
+ def replace(other)
47
+ # FIXME: this should probably be initialize_copy and replace should be in C
48
+ initialize_copy(other)
49
+ end
50
+
32
51
  def self.[](*args)
33
52
  if args.size == 0
34
53
  new
@@ -47,6 +66,27 @@ module Roaring
47
66
  other <= self
48
67
  end
49
68
 
69
+ alias subset? <=
70
+ alias proper_subset? <
71
+ alias superset? >=
72
+ alias proper_superset? >
73
+
74
+ def <=>(other)
75
+ if self == other
76
+ 0
77
+ elsif subset?(other)
78
+ -1
79
+ elsif superset?(other)
80
+ 1
81
+ else
82
+ nil
83
+ end
84
+ end
85
+
86
+ def disjoint?(other)
87
+ !intersect?(other)
88
+ end
89
+
50
90
  def _dump level
51
91
  serialize
52
92
  end
@@ -64,7 +104,12 @@ module Roaring
64
104
  end
65
105
 
66
106
  def inspect
67
- "#<#{self.class} cardinality=#{cardinality}>"
107
+ cardinality = self.cardinality
108
+ if cardinality < 64
109
+ "#<#{self.class} {#{to_a.join(", ")}}>"
110
+ else
111
+ "#<#{self.class} (#{cardinality} values)>"
112
+ end
68
113
  end
69
114
  end
70
115
  end
data/roaring.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
21
21
  spec.files = Dir.chdir(__dir__) do
22
- `git ls-files -z`.split("\x0").reject do |f|
22
+ `git ls-files --recurse-submodules -z`.split("\x0").reject do |f|
23
23
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roaring
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hawthorn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-16 00:00:00.000000000 Z
11
+ date: 2023-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prime
@@ -40,6 +40,11 @@ files:
40
40
  - Rakefile
41
41
  - ext/roaring/cext.c
42
42
  - ext/roaring/extconf.rb
43
+ - ext/roaring/roaring/LICENSE
44
+ - ext/roaring/roaring/README.md
45
+ - ext/roaring/roaring/roaring.c
46
+ - ext/roaring/roaring/roaring.h
47
+ - ext/roaring/roaring/roaring.hh
43
48
  - lib/roaring.rb
44
49
  - lib/roaring/version.rb
45
50
  - roaring.gemspec
@@ -66,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
71
  - !ruby/object:Gem::Version
67
72
  version: '0'
68
73
  requirements: []
69
- rubygems_version: 3.3.3
74
+ rubygems_version: 3.4.6
70
75
  signing_key:
71
76
  specification_version: 4
72
77
  summary: Roaring bitmaps for Ruby