swiss_hash 0.1.0 → 0.1.2
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/CHANGELOG.md +73 -0
- data/LICENSE.txt +1 -1
- data/README.md +199 -73
- data/ext/swiss_hash/swiss_hash.c +709 -114
- data/lib/swiss_hash/version.rb +1 -1
- data/lib/swiss_hash.rb +37 -9
- metadata +4 -7
data/lib/swiss_hash/version.rb
CHANGED
data/lib/swiss_hash.rb
CHANGED
|
@@ -1,22 +1,50 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "swiss_hash/version"
|
|
4
|
-
require_relative "swiss_hash/swiss_hash
|
|
4
|
+
require_relative "swiss_hash/swiss_hash"
|
|
5
5
|
|
|
6
6
|
module SwissHash
|
|
7
7
|
class Hash
|
|
8
|
-
|
|
8
|
+
include Enumerable
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
|
|
10
|
+
def count(*args, &block)
|
|
11
|
+
return size if args.empty? && !block
|
|
12
|
+
|
|
13
|
+
each.count(*args, &block)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def dig(key, *rest)
|
|
17
|
+
value = self[key]
|
|
18
|
+
return value if rest.empty? || value.nil?
|
|
19
|
+
|
|
20
|
+
value.dig(*rest)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def transform_keys!
|
|
24
|
+
return enum_for(:transform_keys!) unless block_given?
|
|
25
|
+
|
|
26
|
+
pairs = to_a
|
|
27
|
+
clear
|
|
28
|
+
pairs.each { |key, value| self[yield(key)] = value }
|
|
12
29
|
self
|
|
13
30
|
end
|
|
14
|
-
alias_method :update, :merge!
|
|
15
31
|
|
|
16
|
-
def
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
def flatten(level = 1)
|
|
33
|
+
to_a.flatten(level)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def ==(other)
|
|
37
|
+
other = other.to_h if other.is_a?(self.class)
|
|
38
|
+
to_h == other
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def eql?(other)
|
|
42
|
+
other = other.to_h if other.is_a?(self.class)
|
|
43
|
+
to_h.eql?(other)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def hash
|
|
47
|
+
to_h.hash
|
|
20
48
|
end
|
|
21
49
|
|
|
22
50
|
def inspect
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swiss_hash
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Roman Haidarov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rake-compiler
|
|
@@ -24,7 +23,6 @@ dependencies:
|
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '1.0'
|
|
27
|
-
description:
|
|
28
26
|
email:
|
|
29
27
|
- roman.haidarov@hey.com
|
|
30
28
|
executables: []
|
|
@@ -32,6 +30,7 @@ extensions:
|
|
|
32
30
|
- ext/swiss_hash/extconf.rb
|
|
33
31
|
extra_rdoc_files: []
|
|
34
32
|
files:
|
|
33
|
+
- CHANGELOG.md
|
|
35
34
|
- LICENSE.txt
|
|
36
35
|
- README.md
|
|
37
36
|
- ext/swiss_hash/extconf.rb
|
|
@@ -42,7 +41,6 @@ homepage: https://github.com/roman-haidarov/swiss_hash
|
|
|
42
41
|
licenses:
|
|
43
42
|
- MIT
|
|
44
43
|
metadata: {}
|
|
45
|
-
post_install_message:
|
|
46
44
|
rdoc_options: []
|
|
47
45
|
require_paths:
|
|
48
46
|
- lib
|
|
@@ -57,8 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
57
55
|
- !ruby/object:Gem::Version
|
|
58
56
|
version: '0'
|
|
59
57
|
requirements: []
|
|
60
|
-
rubygems_version: 3.
|
|
61
|
-
signing_key:
|
|
58
|
+
rubygems_version: 3.6.7
|
|
62
59
|
specification_version: 4
|
|
63
60
|
summary: Swiss Table hash map as a Ruby C extension
|
|
64
61
|
test_files: []
|