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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f55f40648d7d0d09de6b68a07f3555fd6fe67717f5f450a50b615fea04220593
4
- data.tar.gz: 691d5262f6799d6397326a20cdbffe61dc167596f8a2b569dd850967aa7de150
3
+ metadata.gz: c19926d571d23a20dab98df6b329fca0f15387d3a187527a5f38c37605d31ef7
4
+ data.tar.gz: b6a1c74b1607521255be8e00b25c4e3b4f6c736e31a30f36e3afc91869605203
5
5
  SHA512:
6
- metadata.gz: 760bad2ff3a8f01f88cd475bfa47765fa3dd5dc5b64a55654fdbce205d1a6116bc2a930d2eaafaade8c9719709bd0b9cce1045456082a2ac41067d0d94eb33ef
7
- data.tar.gz: 0fe413992bc5406803ec02b5752a2cc7da926592adc2f391862f67236b9657e647d5ee09bbb5d46c54faadb965e43b777c1cbb862ca31989f670afada0dd1f83
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
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-05-28
4
+
5
+ - Initial release
data/Gemfile CHANGED
@@ -9,8 +9,6 @@ gem 'rake', '~> 13.0'
9
9
 
10
10
  gem 'minitest', '~> 5.0'
11
11
 
12
- gem 'standard', '~> 1.7'
13
-
14
12
  gem 'simplecov', '~> 0.21.2'
15
13
 
16
14
  gem 'simplecov-cobertura', '~> 2.1'
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 range_list
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 range_list
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).
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Version
4
- VERSION = "4.1.0"
4
+ VERSION = "4.2.1"
5
5
  end
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 void
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 tag
77
- p 'is nxm gem'
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.0
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-28 00:00:00.000000000 Z
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:
@@ -1,6 +0,0 @@
1
- <component name="InspectionProjectProfileManager">
2
- <profile version="1.0">
3
- <option name="myName" value="Project Default" />
4
- <inspection_tool class="Rubocop" enabled="false" level="WARNING" enabled_by_default="false" />
5
- </profile>
6
- </component>
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>