splay_tree 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +17 -1
- data/README.md +14 -11
- data/Rakefile +0 -2
- data/benchmarks/speed.rb +3 -2
- data/lib/splay_tree.rb +10 -9
- data/lib/splay_tree/node.rb +1 -1
- data/lib/splay_tree/version.rb +2 -2
- data/spec/spec_helper.rb +2 -2
- data/splay_tree.gemspec +10 -7
- metadata +39 -25
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/.ruby-version +0 -1
- data/.travis.yml +0 -22
- data/Gemfile +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7db3333f96bcd04b3f7766c56b55b450adf0005f8f6e89f3502e7d741bf39e53
|
4
|
+
data.tar.gz: 6af03f7dc28f3fde8921cfc16d3a45836e867103934ef63309dbee2937896936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25ab7c5a533c1e9408d14b88851361093d33c43389823933474607b80a615adf2e7970bf2a021278597b53856a6d72e68324e1f1a051939d6284ecd4f3a00006
|
7
|
+
data.tar.gz: 801cecc487afd61c56cab1edfa94cbe3f95b40903e8b95941879c6974a1b6bf12250a7fa988c5c9a17d74eeba44229af2058cd8589ac12a87deeae76cd071d1c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
-
|
1
|
+
# Change log
|
2
|
+
|
3
|
+
## [v0.3.0] - 2019-02-26
|
4
|
+
|
5
|
+
* Change to limit to Ruby >= 2.0.0
|
6
|
+
* Change gemspec to load files directly without git
|
7
|
+
* Change to freeze all strings
|
8
|
+
|
9
|
+
## [v0.2.0] - 2015-01-03
|
2
10
|
|
3
11
|
* Add ability to set default through value and block
|
4
12
|
* Add ability to iterate over keys and values
|
5
13
|
* Add to_hash export
|
14
|
+
|
15
|
+
## [v0.1.0] - 2014-12-27
|
16
|
+
|
17
|
+
* Initial implementation and release
|
18
|
+
|
19
|
+
[v0.3.0]: https://github.com/piotrmurach/splay_tree/compare/v0.2.0...v0.3.0
|
20
|
+
[v0.2.0]: https://github.com/piotrmurach/splay_tree/compare/v0.1.0...v0.2.0
|
21
|
+
[v0.1.0]: https://github.com/piotrmurach/splay_tree/compare/v0.1.0
|
data/README.md
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
# SplayTree
|
2
|
-
|
3
|
-
[![
|
4
|
-
[![
|
5
|
-
[![
|
6
|
-
[![
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/splay_tree.svg)][gem]
|
4
|
+
[![Build Status](https://secure.travis-ci.org/piotrmurach/splay_tree.svg?branch=master)][travis]
|
5
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/smfi5r38ihtn9gom?svg=true)][appveyor]
|
6
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/32d2351f6c349a58d8da/maintainability)][codeclimate]
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/github/piotrmurach/splay_tree/badge.svg?branch=master)][coverage]
|
8
|
+
[![Inline docs](http://inch-ci.org/github/piotrmurach/splay_tree.svg)][inchpages]
|
7
9
|
|
8
10
|
[gem]: http://badge.fury.io/rb/splay_tree
|
9
|
-
[travis]: http://travis-ci.org/
|
10
|
-
[
|
11
|
-
[
|
12
|
-
[
|
11
|
+
[travis]: http://travis-ci.org/piotrmurach/splay_tree
|
12
|
+
[appveyor]: https://ci.appveyor.com/project/piotrmurach/splay-tree
|
13
|
+
[codeclimate]: https://codeclimate.com/github/piotrmurach/splay_tree/maintainability
|
14
|
+
[coverage]: https://coveralls.io/github/piotrmurach/splay_tree
|
15
|
+
[inchpages]: http://inch-ci.org/github/piotrmurach/splay_tree
|
13
16
|
|
14
17
|
> Self balancing binary tree that keeps lookup operations fast by optimizing frequently accessed keys. Useful for implementing caches and garbage collection algorithms.
|
15
18
|
|
@@ -152,7 +155,7 @@ If no block is provided, an enumerator is returned instead.
|
|
152
155
|
|
153
156
|
## Contributing
|
154
157
|
|
155
|
-
1. Fork it ( https://github.com/
|
158
|
+
1. Fork it ( https://github.com/piotrmurach/splay_tree/fork )
|
156
159
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
157
160
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
158
161
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -160,4 +163,4 @@ If no block is provided, an enumerator is returned instead.
|
|
160
163
|
|
161
164
|
## Copyright
|
162
165
|
|
163
|
-
Copyright (c) 2014
|
166
|
+
Copyright (c) 2014 Piotr Murach. See LICENSE for further details.
|
data/Rakefile
CHANGED
data/benchmarks/speed.rb
CHANGED
data/lib/splay_tree.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
require_relative 'splay_tree/node'
|
4
|
+
require_relative 'splay_tree/version'
|
5
5
|
|
6
6
|
class SplayTree
|
7
7
|
include Enumerable
|
@@ -26,10 +26,10 @@ class SplayTree
|
|
26
26
|
# @api public
|
27
27
|
def initialize(default = UndefinedValue, &block)
|
28
28
|
if !UndefinedValue.equal?(default) && block
|
29
|
-
|
30
|
-
|
29
|
+
raise ArgumentError,
|
30
|
+
"You need to pass either argument or a block as a default value"
|
31
31
|
end
|
32
|
-
@root
|
32
|
+
@root = Node::EMPTY
|
33
33
|
@subtree = Node.new(nil, nil)
|
34
34
|
@default = default
|
35
35
|
@default_proc = block
|
@@ -44,7 +44,7 @@ class SplayTree
|
|
44
44
|
def size
|
45
45
|
@root.size
|
46
46
|
end
|
47
|
-
|
47
|
+
alias length size
|
48
48
|
|
49
49
|
# Iterate over each key & value pair in the tree
|
50
50
|
#
|
@@ -153,7 +153,7 @@ class SplayTree
|
|
153
153
|
|
154
154
|
splay(key)
|
155
155
|
end
|
156
|
-
|
156
|
+
alias insert []=
|
157
157
|
|
158
158
|
# Find object by the key
|
159
159
|
#
|
@@ -168,7 +168,7 @@ class SplayTree
|
|
168
168
|
|
169
169
|
@root.value
|
170
170
|
end
|
171
|
-
|
171
|
+
alias fetch []
|
172
172
|
|
173
173
|
# Check if tree contains a node with a matching key.
|
174
174
|
#
|
@@ -177,6 +177,7 @@ class SplayTree
|
|
177
177
|
# @api public
|
178
178
|
def key?(key)
|
179
179
|
return false if @root.empty?
|
180
|
+
|
180
181
|
splay(key)
|
181
182
|
@root.key == key
|
182
183
|
end
|
data/lib/splay_tree/node.rb
CHANGED
data/lib/splay_tree/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/splay_tree.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'splay_tree/version'
|
@@ -7,16 +6,20 @@ Gem::Specification.new do |spec|
|
|
7
6
|
spec.name = "splay_tree"
|
8
7
|
spec.version = SplayTree::VERSION
|
9
8
|
spec.authors = ["Piotr Murach"]
|
10
|
-
spec.email = [""]
|
9
|
+
spec.email = ["me@piotrmurach.com"]
|
11
10
|
spec.summary = %q{A self-balancing binary tree with amortized access.}
|
12
11
|
spec.description = %q{Self balancing binary tree that keeps lookup operations fast by optimizing frequently accessed keys. Useful for implementing caches and garbage collection algorithms.}
|
13
|
-
spec.homepage = "https://github.com/
|
12
|
+
spec.homepage = "https://github.com/piotrmurach/splay_tree"
|
14
13
|
spec.license = "MIT"
|
15
14
|
|
16
|
-
spec.files =
|
17
|
-
spec.
|
18
|
-
spec.
|
15
|
+
spec.files = Dir['{lib,spec,benchmarks}/**/*.rb']
|
16
|
+
spec.files += Dir['tasks/*', 'splay_tree.gemspec']
|
17
|
+
spec.files += Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt', 'Rakefile']
|
19
18
|
spec.require_paths = ["lib"]
|
20
19
|
|
21
|
-
spec.
|
20
|
+
spec.required_ruby_version = '>= 2.0.0'
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
22
25
|
end
|
metadata
CHANGED
@@ -1,44 +1,67 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: splay_tree
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
27
55
|
description: Self balancing binary tree that keeps lookup operations fast by optimizing
|
28
56
|
frequently accessed keys. Useful for implementing caches and garbage collection
|
29
57
|
algorithms.
|
30
58
|
email:
|
31
|
-
-
|
59
|
+
- me@piotrmurach.com
|
32
60
|
executables: []
|
33
61
|
extensions: []
|
34
62
|
extra_rdoc_files: []
|
35
63
|
files:
|
36
|
-
- .gitignore
|
37
|
-
- .rspec
|
38
|
-
- .ruby-version
|
39
|
-
- .travis.yml
|
40
64
|
- CHANGELOG.md
|
41
|
-
- Gemfile
|
42
65
|
- LICENSE.txt
|
43
66
|
- README.md
|
44
67
|
- Rakefile
|
@@ -58,7 +81,7 @@ files:
|
|
58
81
|
- tasks/console.rake
|
59
82
|
- tasks/coverage.rake
|
60
83
|
- tasks/spec.rake
|
61
|
-
homepage: https://github.com/
|
84
|
+
homepage: https://github.com/piotrmurach/splay_tree
|
62
85
|
licenses:
|
63
86
|
- MIT
|
64
87
|
metadata: {}
|
@@ -68,27 +91,18 @@ require_paths:
|
|
68
91
|
- lib
|
69
92
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
93
|
requirements:
|
71
|
-
- -
|
94
|
+
- - ">="
|
72
95
|
- !ruby/object:Gem::Version
|
73
|
-
version:
|
96
|
+
version: 2.0.0
|
74
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
98
|
requirements:
|
76
|
-
- -
|
99
|
+
- - ">="
|
77
100
|
- !ruby/object:Gem::Version
|
78
101
|
version: '0'
|
79
102
|
requirements: []
|
80
103
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
104
|
+
rubygems_version: 2.7.3
|
82
105
|
signing_key:
|
83
106
|
specification_version: 4
|
84
107
|
summary: A self-balancing binary tree with amortized access.
|
85
|
-
test_files:
|
86
|
-
- spec/spec_helper.rb
|
87
|
-
- spec/unit/default_spec.rb
|
88
|
-
- spec/unit/delete_spec.rb
|
89
|
-
- spec/unit/each_spec.rb
|
90
|
-
- spec/unit/fetch_spec.rb
|
91
|
-
- spec/unit/insert_spec.rb
|
92
|
-
- spec/unit/new_spec.rb
|
93
|
-
- spec/unit/to_hash_spec.rb
|
94
|
-
has_rdoc:
|
108
|
+
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.0
|
data/.travis.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
bundler_args: --without yard benchmarks
|
3
|
-
script: "bundle exec rake ci"
|
4
|
-
rvm:
|
5
|
-
- 1.9.3
|
6
|
-
- 2.0.0
|
7
|
-
- 2.1.0
|
8
|
-
- 2.2.0
|
9
|
-
- ruby-head
|
10
|
-
matrix:
|
11
|
-
include:
|
12
|
-
- rvm: jruby-19mode
|
13
|
-
- rvm: jruby-20mode
|
14
|
-
- rvm: jruby-21mode
|
15
|
-
- rvm: jruby-head
|
16
|
-
- rvm: rbx-2
|
17
|
-
allow_failures:
|
18
|
-
- rvm: ruby-head
|
19
|
-
- rvm: jruby-head
|
20
|
-
fast_finish: true
|
21
|
-
branches:
|
22
|
-
only: master
|
data/Gemfile
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
source 'https://rubygems.org'
|
2
|
-
|
3
|
-
gemspec
|
4
|
-
|
5
|
-
group :development do
|
6
|
-
gem 'rake', '~> 10.3.2'
|
7
|
-
gem 'rspec', '~> 3.1.0'
|
8
|
-
gem 'yard', '~> 0.8.7'
|
9
|
-
gem 'timecop', '~> 0.7.1'
|
10
|
-
gem 'benchmark-ips', '~> 2.0.0'
|
11
|
-
end
|
12
|
-
|
13
|
-
group :metrics do
|
14
|
-
gem 'coveralls', '~> 0.7.0'
|
15
|
-
gem 'simplecov', '~> 0.8.2'
|
16
|
-
gem 'yardstick', '~> 0.9.9'
|
17
|
-
end
|