range_list_nxm 4.1.0 → 4.2.1
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/.idea/sonarlint/issuestore/index.pb +0 -9
- data/CHANGELOG.md +5 -0
- data/Gemfile +0 -2
- data/README.md +16 -3
- data/lib/range_list/version.rb +1 -1
- data/lib/range_list.rb +12 -3
- metadata +3 -8
- data/.idea/inspectionProfiles/Project_Default.xml +0 -6
- data/.idea/sonarlint/issuestore/0/8/0834ae016f8fea5cff771880c0be1d55299732ff +0 -0
- data/.idea/sonarlint/issuestore/2/b/2b22d59fcdaf24a6d2536513e514e77fc83391a3 +0 -0
- data/.idea/sonarlint/issuestore/7/9/79b82ce9b64a924266619555502f890dd80c83b9 +0 -0
- data/.idea/sonarlint/issuestore/9/f/9fe84ebb15faf917b7def6236dba604453cc61e0 +0 -0
- data/range_list.iml +0 -64
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c19926d571d23a20dab98df6b329fca0f15387d3a187527a5f38c37605d31ef7
|
4
|
+
data.tar.gz: b6a1c74b1607521255be8e00b25c4e3b4f6c736e31a30f36e3afc91869605203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b58b0c809c626cb5bbc2cd3df1b299d8f8d44cf848a87109e980b083be95979f63d7a06758ed779b70d7a7b93209837035b62c849a546cae73464a5f9d974e81
|
7
|
+
data.tar.gz: 55937b4d992141ed64731b7253c4f529afafea5fabc3ab3720919ed5818ebe3c338ff32dd6841cbcb604c68d68c948c986acd4085ffd91ec656d42fb210ebb26
|
@@ -1,9 +0,0 @@
|
|
1
|
-
|
2
|
-
S
|
3
|
-
#.idea/sonarlint/issuestore/index.pb,9/f/9fe84ebb15faf917b7def6236dba604453cc61e0
|
4
|
-
;
|
5
|
-
LICENSE.txt,7/9/79b82ce9b64a924266619555502f890dd80c83b9
|
6
|
-
B
|
7
|
-
CODE_OF_CONDUCT.md,0/8/0834ae016f8fea5cff771880c0be1d55299732ff
|
8
|
-
;
|
9
|
-
bin/console,2/b/2b22d59fcdaf24a6d2536513e514e77fc83391a3
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,20 +5,31 @@ RangeList is a quick Range Query Library
|
|
5
5
|
A pair of integers define a range, for example: [1, 5). This range includes integers: 1, 2, 3, and 4.
|
6
6
|
A range list is an aggregate of these ranges: [10, 11), [100, 201). This range includes integers: 10, 100, 101, ... 200.
|
7
7
|
|
8
|
+
RangeList It uses red and black tree to ensure the operation efficiency and the use of additional memory
|
9
|
+
|
10
|
+
The time complexity of add() method and remove() method is log(n)
|
11
|
+
|
12
|
+
[Gem](https://rubygems.org/gems/range_list_nxm)
|
13
|
+
|
14
|
+
[desc](https://gitlab.com/ningxiaoming/range_list/-/blob/master/README.md)
|
15
|
+
|
16
|
+
[pipeline](https://jihulab.com/kimi/range_list_v1/-/jobs/2940728)
|
8
17
|
|
9
18
|
## Installation
|
10
19
|
|
11
20
|
Install the gem and add to the application's Gemfile by executing:
|
12
21
|
|
13
|
-
$ bundle add
|
22
|
+
$ bundle add range_list_nxm
|
14
23
|
|
15
24
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
25
|
|
17
|
-
$ gem install
|
26
|
+
$ gem install range_list_nxm
|
18
27
|
|
19
28
|
|
20
29
|
## Usage
|
21
30
|
```shell
|
31
|
+
require "range_list"
|
32
|
+
|
22
33
|
rl = RangeList.new
|
23
34
|
rl.add([1, 5])
|
24
35
|
rl.print ## Should display: [1, 5)
|
@@ -49,6 +60,8 @@ rl.print ## Should display: [1, 8) [11, 15) [17, 21)
|
|
49
60
|
|
50
61
|
rl.remove([3, 19])
|
51
62
|
rl.print ## Should display: [1, 3) [19, 21)
|
63
|
+
|
64
|
+
result = rl.query_all ## result: {1=>3, 19=>21}
|
52
65
|
```
|
53
66
|
|
54
67
|
## Development
|
@@ -62,4 +75,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
62
75
|
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/ningxiaoming/range_list
|
63
76
|
## License
|
64
77
|
|
65
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
78
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/range_list/version.rb
CHANGED
data/lib/range_list.rb
CHANGED
@@ -12,7 +12,7 @@ class RangeList
|
|
12
12
|
# Add range to rangeList
|
13
13
|
# @param [Array<Integer>] range is a range.range.length must be 2,the range[0] is range start,range[1] is range end
|
14
14
|
# range[0] must be less than or equal to range[0]
|
15
|
-
# @return
|
15
|
+
# @return nil
|
16
16
|
# @raise ArgumentError
|
17
17
|
def add(range)
|
18
18
|
validate_param(range)
|
@@ -43,6 +43,11 @@ class RangeList
|
|
43
43
|
nil
|
44
44
|
end
|
45
45
|
|
46
|
+
# Remove range to rangeList
|
47
|
+
# @param [Array<Integer>] range is a range. range length must be 2,the range[0] is range start,range[1] is range end
|
48
|
+
# range[0] must be less than or equal to range[0]
|
49
|
+
# @return nil
|
50
|
+
# @raise ArgumentError
|
46
51
|
def remove(range)
|
47
52
|
validate_param(range)
|
48
53
|
return if range[0] == range[1]
|
@@ -73,8 +78,12 @@ class RangeList
|
|
73
78
|
puts item[0, item.length - 1]
|
74
79
|
end
|
75
80
|
|
76
|
-
def
|
77
|
-
|
81
|
+
def query_all
|
82
|
+
res_hash = {}
|
83
|
+
@red_black_tree_impl.each do |k,v|
|
84
|
+
res_hash[k] = v
|
85
|
+
end
|
86
|
+
res_hash
|
78
87
|
end
|
79
88
|
|
80
89
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: range_list_nxm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xiaoming.ning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbtree
|
@@ -32,16 +32,12 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- ".idea/.gitignore"
|
35
|
-
- ".idea/inspectionProfiles/Project_Default.xml"
|
36
35
|
- ".idea/misc.xml"
|
37
36
|
- ".idea/modules.xml"
|
38
37
|
- ".idea/runConfigurations.xml"
|
39
|
-
- ".idea/sonarlint/issuestore/0/8/0834ae016f8fea5cff771880c0be1d55299732ff"
|
40
|
-
- ".idea/sonarlint/issuestore/2/b/2b22d59fcdaf24a6d2536513e514e77fc83391a3"
|
41
|
-
- ".idea/sonarlint/issuestore/7/9/79b82ce9b64a924266619555502f890dd80c83b9"
|
42
|
-
- ".idea/sonarlint/issuestore/9/f/9fe84ebb15faf917b7def6236dba604453cc61e0"
|
43
38
|
- ".idea/sonarlint/issuestore/index.pb"
|
44
39
|
- ".idea/vcs.xml"
|
40
|
+
- CHANGELOG.md
|
45
41
|
- CODE_OF_CONDUCT.md
|
46
42
|
- Gemfile
|
47
43
|
- LICENSE.txt
|
@@ -52,7 +48,6 @@ files:
|
|
52
48
|
- lib/range_list/infrastructure/not_impl_hash.rb
|
53
49
|
- lib/range_list/infrastructure/red_black_tree_impl.rb
|
54
50
|
- lib/range_list/version.rb
|
55
|
-
- range_list.iml
|
56
51
|
- sig/range_list.rbs
|
57
52
|
homepage: https://gitlab.com/ningxiaoming/range_list
|
58
53
|
licenses:
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/range_list.iml
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
|
-
<exclude-output />
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
6
|
-
<orderEntry type="jdk" jdkName="RVM: ruby-3.0.0" jdkType="RUBY_SDK" />
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
8
|
-
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-3.0.0) [gem]" level="application" />
|
9
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.14, RVM: ruby-3.0.0) [gem]" level="application" />
|
10
|
-
<orderEntry type="library" scope="PROVIDED" name="docile (v1.4.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
11
|
-
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
12
|
-
<orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
13
|
-
<orderEntry type="library" scope="PROVIDED" name="parser (v3.1.1.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
14
|
-
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-3.0.0) [gem]" level="application" />
|
15
|
-
<orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-3.0.0) [gem]" level="application" />
|
16
|
-
<orderEntry type="library" scope="PROVIDED" name="rbs (v1.0.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
17
|
-
<orderEntry type="library" scope="PROVIDED" name="rbtree (v0.4.5, RVM: ruby-3.0.0) [gem]" level="application" />
|
18
|
-
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.4.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
19
|
-
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-3.0.0) [gem]" level="application" />
|
20
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.25.1, RVM: ruby-3.0.0) [gem]" level="application" />
|
21
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.16.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
22
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-performance (v1.13.2, RVM: ruby-3.0.0) [gem]" level="application" />
|
23
|
-
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
24
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov (v0.21.2, RVM: ruby-3.0.0) [gem]" level="application" />
|
25
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov-cobertura (v2.1.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
26
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov-html (v0.12.3, RVM: ruby-3.0.0) [gem]" level="application" />
|
27
|
-
<orderEntry type="library" scope="PROVIDED" name="simplecov_json_formatter (v0.1.4, RVM: ruby-3.0.0) [gem]" level="application" />
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="standard (v1.7.2, RVM: ruby-3.0.0) [gem]" level="application" />
|
29
|
-
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, RVM: ruby-3.0.0) [gem]" level="application" />
|
30
|
-
</component>
|
31
|
-
<component name="RakeTasksCache">
|
32
|
-
<option name="myRootTask">
|
33
|
-
<RakeTaskImpl id="rake">
|
34
|
-
<subtasks>
|
35
|
-
<RakeTaskImpl description="Build range_list-1.4.1.gem into the pkg directory" fullCommand="build" id="build" />
|
36
|
-
<RakeTaskImpl id="build">
|
37
|
-
<subtasks>
|
38
|
-
<RakeTaskImpl description="Generate SHA512 checksum if range_list-1.4.1.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
39
|
-
</subtasks>
|
40
|
-
</RakeTaskImpl>
|
41
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
42
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
43
|
-
<RakeTaskImpl description="Build and install range_list-1.4.1.gem into system gems" fullCommand="install" id="install" />
|
44
|
-
<RakeTaskImpl id="install">
|
45
|
-
<subtasks>
|
46
|
-
<RakeTaskImpl description="Build and install range_list-1.4.1.gem into system gems without network access" fullCommand="install:local" id="local" />
|
47
|
-
</subtasks>
|
48
|
-
</RakeTaskImpl>
|
49
|
-
<RakeTaskImpl description="Create tag v1.4.1 and build and push range_list-1.4.1.gem to rubygems.org" fullCommand="release[remote]" id="release[remote]" />
|
50
|
-
<RakeTaskImpl description="Run tests" fullCommand="test" id="test" />
|
51
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
52
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
53
|
-
<RakeTaskImpl id="release">
|
54
|
-
<subtasks>
|
55
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
56
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
57
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
58
|
-
</subtasks>
|
59
|
-
</RakeTaskImpl>
|
60
|
-
</subtasks>
|
61
|
-
</RakeTaskImpl>
|
62
|
-
</option>
|
63
|
-
</component>
|
64
|
-
</module>
|