algorithmable 0.14.0 → 0.15.0
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/lib/algorithmable/cache.rb +3 -0
- data/lib/algorithmable/cache/imp.rb +1 -1
- data/lib/algorithmable/cache/methods.rb +16 -0
- data/lib/algorithmable/cache/primitive_max_heap.rb +2 -5
- data/lib/algorithmable/cache/primitive_min_heap.rb +2 -5
- data/lib/algorithmable/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7cc55555926e43646d71cbee211f801060920888
|
4
|
+
data.tar.gz: 14adcb09b5e3cd5f656ec0a8790991497079a66f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6baa727db4733da616191809992a85be13518dbdc41e086e4c5497537fec2baf6f3f13743cc3e7f68db37cd0841b66950167937629c3c91dfb6915c56881b3e
|
7
|
+
data.tar.gz: fbabc1308ccc5b6774889d1b6b96b6fe9301d8de5c300b99cdeec13678fe6c6fe8b4ce2b6cb8747af36597d159f947ac859bb1fb7608f239da3337fbf4871972
|
data/lib/algorithmable/cache.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
module Algorithmable
|
2
2
|
module Cache
|
3
3
|
autoload :Imp, 'algorithmable/cache/imp'
|
4
|
+
autoload :Methods, 'algorithmable/cache/methods'
|
4
5
|
autoload :PrimitiveMinHeap, 'algorithmable/cache/primitive_min_heap'
|
5
6
|
autoload :PrimitiveMaxHeap, 'algorithmable/cache/primitive_max_heap'
|
6
7
|
|
8
|
+
private_constant :Imp
|
9
|
+
|
7
10
|
def new_lru_cache(size, heap = PrimitiveMaxHeap.new)
|
8
11
|
Imp.new size, heap
|
9
12
|
end
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Algorithmable
|
2
2
|
module Cache
|
3
3
|
class PrimitiveMaxHeap
|
4
|
+
include Algorithmable::Cache::Methods
|
4
5
|
extend Forwardable
|
5
6
|
|
6
7
|
def_delegators :@index, :size, :empty?
|
8
|
+
def_delegators :@storage, :key?
|
7
9
|
|
8
10
|
def initialize(index = [])
|
9
11
|
@storage = {}
|
@@ -21,11 +23,6 @@ module Algorithmable
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
def pop
|
25
|
-
key = @index.delete @index.last
|
26
|
-
@storage.delete key
|
27
|
-
end
|
28
|
-
|
29
26
|
private
|
30
27
|
|
31
28
|
def swim(key)
|
@@ -1,9 +1,11 @@
|
|
1
1
|
module Algorithmable
|
2
2
|
module Cache
|
3
3
|
class PrimitiveMinHeap
|
4
|
+
include Algorithmable::Cache::Methods
|
4
5
|
extend Forwardable
|
5
6
|
|
6
7
|
def_delegators :@index, :size, :empty?
|
8
|
+
def_delegators :@storage, :key?
|
7
9
|
|
8
10
|
def initialize(index = [])
|
9
11
|
@storage = {}
|
@@ -21,11 +23,6 @@ module Algorithmable
|
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
24
|
-
def pop
|
25
|
-
key = @index.delete @index.last
|
26
|
-
@storage.delete key
|
27
|
-
end
|
28
|
-
|
29
26
|
private
|
30
27
|
|
31
28
|
def sink(key)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algorithmable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Lishtaba
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- lib/algorithmable.rb
|
157
157
|
- lib/algorithmable/cache.rb
|
158
158
|
- lib/algorithmable/cache/imp.rb
|
159
|
+
- lib/algorithmable/cache/methods.rb
|
159
160
|
- lib/algorithmable/cache/primitive_max_heap.rb
|
160
161
|
- lib/algorithmable/cache/primitive_min_heap.rb
|
161
162
|
- lib/algorithmable/cups.rb
|