interval_set 0.1.0.pre.RC1 → 0.1.0.pre.SNAPSHOT
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -15
- data/README.md +5 -5
- data/Rakefile +8 -7
- data/bin/console +1 -1
- data/interval_set.gemspec +1 -1
- data/lib/interval_set/version.rb +1 -1
- data/lib/interval_set.rb +22 -26
- metadata +3 -4
- data/.rspec +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcccff0b79c5c4336c91dae3bb64341dce4eba50
|
4
|
+
data.tar.gz: a9af7af763952619b651bc5a014b50a6d9622ecc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9abbfbb43e9da0be6c8c7daef8444e978f9c91c5443b759f2d62283b46174b5ee3f746e8b58466a8261106c328f13de61d051064e688f816673db274e379980
|
7
|
+
data.tar.gz: 5310ee26f32e2ddb203aa0b9a0abbc225ce2fdd6f3f90895ff92359dc0db4d317ad5dd6b0626ac7d7b2678cd84c5996570f5b63a476d6cd314449c9d0dbe5aa6
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -7,22 +7,8 @@ PATH
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
diff-lcs (1.3)
|
11
10
|
minitest (5.10.3)
|
12
11
|
rake (10.5.0)
|
13
|
-
rspec (3.7.0)
|
14
|
-
rspec-core (~> 3.7.0)
|
15
|
-
rspec-expectations (~> 3.7.0)
|
16
|
-
rspec-mocks (~> 3.7.0)
|
17
|
-
rspec-core (3.7.0)
|
18
|
-
rspec-support (~> 3.7.0)
|
19
|
-
rspec-expectations (3.7.0)
|
20
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
-
rspec-support (~> 3.7.0)
|
22
|
-
rspec-mocks (3.7.0)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.7.0)
|
25
|
-
rspec-support (3.7.0)
|
26
12
|
treemap-fork (1.0.4.2)
|
27
13
|
|
28
14
|
PLATFORMS
|
@@ -33,7 +19,6 @@ DEPENDENCIES
|
|
33
19
|
interval_set!
|
34
20
|
minitest (~> 5.0)
|
35
21
|
rake (~> 10.0)
|
36
|
-
rspec (~> 3.7)
|
37
22
|
|
38
23
|
BUNDLED WITH
|
39
24
|
1.16.0
|
data/README.md
CHANGED
@@ -16,11 +16,11 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install
|
19
|
+
$ gem install rangeset
|
20
20
|
|
21
21
|
## Documentation
|
22
22
|
|
23
|
-
http://www.rubydoc.info/
|
23
|
+
http://www.rubydoc.info/github/rjasper/rangeset
|
24
24
|
|
25
25
|
## Usage
|
26
26
|
|
@@ -254,13 +254,13 @@ i.shift!(1) # -> [2000-01-02...2000-01-04]
|
|
254
254
|
|
255
255
|
## Development
|
256
256
|
|
257
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
257
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
258
258
|
|
259
259
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
260
260
|
|
261
261
|
## Contributing
|
262
262
|
|
263
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/rjasper/
|
263
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/rjasper/rangeset. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
264
264
|
|
265
265
|
## License
|
266
266
|
|
@@ -268,4 +268,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
268
268
|
|
269
269
|
## Code of Conduct
|
270
270
|
|
271
|
-
Everyone interacting in the
|
271
|
+
Everyone interacting in the Rangeset project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rjasper/rangeset/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# no rspec available
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
9
8
|
end
|
9
|
+
|
10
|
+
task :default => :test
|
data/bin/console
CHANGED
data/interval_set.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['jasper.rico@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = 'Set of sorted non-overlapping ranges'
|
13
|
-
spec.homepage = 'https://github.com/rjasper/
|
13
|
+
spec.homepage = 'https://github.com/rjasper/interval_set'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/lib/interval_set/version.rb
CHANGED
data/lib/interval_set.rb
CHANGED
@@ -15,8 +15,8 @@ class IntervalSet
|
|
15
15
|
# array = [0...1, 2...3]
|
16
16
|
# IntervalSet[*array] # -> [0...1, 2...3]
|
17
17
|
#
|
18
|
-
# @param ranges [Range[]] a list of ranges to be added to the new
|
19
|
-
# @return [IntervalSet] a new
|
18
|
+
# @param ranges [Range[]] a list of ranges to be added to the new Rangeset
|
19
|
+
# @return [IntervalSet] a new RangeSet containing the supplied ranges.
|
20
20
|
def self.[](*ranges)
|
21
21
|
IntervalSet.new.tap do |interval_set|
|
22
22
|
ranges.each {|range| interval_set << range}
|
@@ -70,14 +70,15 @@ class IntervalSet
|
|
70
70
|
empty? ? nil : min...max
|
71
71
|
end
|
72
72
|
|
73
|
-
# Returns +true+ if two
|
73
|
+
# Returns +true+ if two RangeSets are equal.
|
74
74
|
#
|
75
75
|
# IntervalSet[0...1] == IntervalSet[0...1] # -> true
|
76
76
|
# IntervalSet[0...1] == IntervalSet[1...2] # -> false
|
77
77
|
#
|
78
|
-
# @param other [
|
78
|
+
# @param other [IntervalSet] the other RangeSet.
|
79
79
|
def eql?(other)
|
80
|
-
return false if
|
80
|
+
return false if count != other.count
|
81
|
+
return false if bounds != other.bounds
|
81
82
|
|
82
83
|
lhs_iter = enum_for
|
83
84
|
rhs_iter = other.enum_for
|
@@ -113,13 +114,8 @@ class IntervalSet
|
|
113
114
|
# i.include?(0.5) # -> true
|
114
115
|
# i.include?(1) # -> false ; a range's end is exclusive
|
115
116
|
#
|
116
|
-
# Note that the given element must be comparable to elements already in this
|
117
|
-
# set. Otherwise, the behavior is undefined.
|
118
|
-
#
|
119
117
|
# @param element [Object]
|
120
118
|
def include?(element)
|
121
|
-
return false if element.nil?
|
122
|
-
|
123
119
|
floor_entry = @range_map.floor_entry(element)
|
124
120
|
|
125
121
|
!floor_entry.nil? && floor_entry.value.last > element
|
@@ -241,17 +237,17 @@ class IntervalSet
|
|
241
237
|
#
|
242
238
|
# i = IntervalSet[0...1] # -> [0...1]
|
243
239
|
#
|
244
|
-
# # Ranges only need a single common element with the
|
240
|
+
# # Ranges only need a single common element with the range set
|
245
241
|
# i.intersect?(0...1) # -> true
|
246
242
|
# i.intersect?(0...2) # -> true
|
247
243
|
# i.intersect?(1...2) # -> false ; the start of a range is inclusive but the end exclusive
|
248
244
|
#
|
249
|
-
# # The same applies for
|
245
|
+
# # The same applies for range sets
|
250
246
|
# i.intersect?(IntervalSet[0...1]) # -> true
|
251
247
|
# i.intersect?(IntervalSet[0...1, 2...3]) # -> true
|
252
248
|
# i.intersect?(IntervalSet[2...3]) # -> false
|
253
249
|
#
|
254
|
-
# @param other [Range | IntervalSet] the other object.
|
250
|
+
# @param other [Range | IntervalSet | #<=>] the other object.
|
255
251
|
def intersect?(other)
|
256
252
|
case other
|
257
253
|
when Range
|
@@ -274,7 +270,7 @@ class IntervalSet
|
|
274
270
|
# i << (1...2) # -> [0...3]
|
275
271
|
# i.count # -> 1
|
276
272
|
#
|
277
|
-
# @return [
|
273
|
+
# @return [Integer] the number of ranges.
|
278
274
|
def count
|
279
275
|
@range_map.count
|
280
276
|
end
|
@@ -357,7 +353,7 @@ class IntervalSet
|
|
357
353
|
# IntervalSet[0...2, 3...5] & IntervalSet[1...4, 5...6] # -> [1...2, 3...4]
|
358
354
|
#
|
359
355
|
# @param other [Range, IntervalSet] the other object.
|
360
|
-
# @return [IntervalSet] a new
|
356
|
+
# @return [IntervalSet] a new RangeSet containing the intersection.
|
361
357
|
def intersection(other)
|
362
358
|
case other
|
363
359
|
when Range
|
@@ -380,7 +376,7 @@ class IntervalSet
|
|
380
376
|
# <code>+=</code> or <code>|=</code>.
|
381
377
|
#
|
382
378
|
# @param other [Range, IntervalSet] the other object.
|
383
|
-
# @return [IntervalSet] a new
|
379
|
+
# @return [IntervalSet] a new RangeSet containing the union.
|
384
380
|
def union(other)
|
385
381
|
case other
|
386
382
|
when Range
|
@@ -404,7 +400,7 @@ class IntervalSet
|
|
404
400
|
# than <code>-=</code>.
|
405
401
|
#
|
406
402
|
# @param other [Range, IntervalSet] the other object.
|
407
|
-
# @return [IntervalSet] a new
|
403
|
+
# @return [IntervalSet] a new RangeSet containing the difference.
|
408
404
|
def difference(other)
|
409
405
|
case other
|
410
406
|
when Range
|
@@ -428,7 +424,7 @@ class IntervalSet
|
|
428
424
|
# IntervalSet[0...1] ^ IntervalSet[0...1] # -> []
|
429
425
|
#
|
430
426
|
# @param other [Range, IntervalSet]
|
431
|
-
# @return [IntervalSet] a new
|
427
|
+
# @return [IntervalSet] a new RangeSet containing the exclusive set.
|
432
428
|
def xor(other)
|
433
429
|
clone.xor!(other)
|
434
430
|
end
|
@@ -446,7 +442,7 @@ class IntervalSet
|
|
446
442
|
# IntervalSet[0...1].xor!(IntervalSet[0...1]) # -> []
|
447
443
|
#
|
448
444
|
# @param other [Range, IntervalSet]
|
449
|
-
# @return [IntervalSet] a new
|
445
|
+
# @return [IntervalSet] a new RangeSet containing the exclusive set.
|
450
446
|
def xor!(other)
|
451
447
|
intersection = self & other
|
452
448
|
|
@@ -466,7 +462,7 @@ class IntervalSet
|
|
466
462
|
# IntervalSet[0...4].convolve!(0...0) # -> []
|
467
463
|
# IntervalSet[0...4].convolve!(1...0) # -> []
|
468
464
|
#
|
469
|
-
# # Convolve with a
|
465
|
+
# # Convolve with a range set
|
470
466
|
# IntervalSet[0...1, 10...12].convolve!(IntervalSet[-2...1, 1...2]) # -> [-2...3, 8...14]
|
471
467
|
#
|
472
468
|
# @param other [Range | IntervalSet] the other object.
|
@@ -495,11 +491,11 @@ class IntervalSet
|
|
495
491
|
# IntervalSet[0...4] * (0...0) # -> []
|
496
492
|
# IntervalSet[0...4] * (1...0) # -> []
|
497
493
|
#
|
498
|
-
# # Convolve with a
|
494
|
+
# # Convolve with a range set
|
499
495
|
# IntervalSet[0...1, 10...12] * IntervalSet[-2...1, 1...2] # -> [-2...3, 8...14]
|
500
496
|
#
|
501
497
|
# @param other [Range | IntervalSet] the other object.
|
502
|
-
# @return [IntervalSet] a new
|
498
|
+
# @return [IntervalSet] a new RangeSet containing the convolution.
|
503
499
|
def convolve(other)
|
504
500
|
clone.convolve!(other)
|
505
501
|
end
|
@@ -534,7 +530,7 @@ class IntervalSet
|
|
534
530
|
# not assume numbers as element type.
|
535
531
|
#
|
536
532
|
# @param amount [Object]
|
537
|
-
# @return [IntervalSet] a new
|
533
|
+
# @return [IntervalSet] a new RangeSet shifted by +amount+.
|
538
534
|
def shift(amount)
|
539
535
|
clone.shift!(amount)
|
540
536
|
end
|
@@ -575,7 +571,7 @@ class IntervalSet
|
|
575
571
|
#
|
576
572
|
# @param left [Object] margin added to the left side of each range.
|
577
573
|
# @param right [Object] margin added to the right side of each range.
|
578
|
-
# @return [IntervalSet] a new
|
574
|
+
# @return [IntervalSet] a new RangeSet containing the buffered ranges.
|
579
575
|
def buffer(left, right)
|
580
576
|
clone.buffer!(left, right)
|
581
577
|
end
|
@@ -605,7 +601,7 @@ class IntervalSet
|
|
605
601
|
end
|
606
602
|
|
607
603
|
# Replaces the content of this IntervalSet by the content of the given IntervalSet.
|
608
|
-
# @param interval_set [IntervalSet] the other
|
604
|
+
# @param interval_set [IntervalSet] the other RangeSet to be copied
|
609
605
|
# @return [IntervalSet] self.
|
610
606
|
def copy(interval_set)
|
611
607
|
clear
|
@@ -987,7 +983,7 @@ class IntervalSet
|
|
987
983
|
def self.normalize_range(range)
|
988
984
|
range.exclude_end? ? range : range.first...range.last
|
989
985
|
end
|
990
|
-
|
986
|
+
|
991
987
|
def self.unexpected_object(object)
|
992
988
|
raise ArgumentError.new("unexpected object #{object}")
|
993
989
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interval_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.SNAPSHOT
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rico Jasper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,6 @@ extensions: []
|
|
80
80
|
extra_rdoc_files: []
|
81
81
|
files:
|
82
82
|
- ".gitignore"
|
83
|
-
- ".rspec"
|
84
83
|
- ".travis.yml"
|
85
84
|
- CODE_OF_CONDUCT.md
|
86
85
|
- Gemfile
|
@@ -93,7 +92,7 @@ files:
|
|
93
92
|
- interval_set.gemspec
|
94
93
|
- lib/interval_set.rb
|
95
94
|
- lib/interval_set/version.rb
|
96
|
-
homepage: https://github.com/rjasper/
|
95
|
+
homepage: https://github.com/rjasper/interval_set
|
97
96
|
licenses:
|
98
97
|
- MIT
|
99
98
|
metadata: {}
|
data/.rspec
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--require spec_helper
|