data_structures_101 0.2.1 → 0.2.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/lib/data_structures_101/chained_hash_table.rb +10 -0
- data/lib/data_structures_101/hash/base_hash_table.rb +10 -1
- data/lib/data_structures_101/hash/bucket.rb +8 -1
- data/lib/data_structures_101/probe_hash_table.rb +8 -0
- data/lib/data_structures_101/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a5ee7c74cd4fd38e119bb0058e562d7e8b165a9
|
4
|
+
data.tar.gz: bd3ee1e47e446c1a1030c2fb691af1347ffe18e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac3297439e7fc41529aa29c6657765dfbcdf56bec8c6e17454ff8ad607baca4a24f5f922ed85a12eae9aea9f950c5cb7b5432f4b0142f4f6c9c0670ed0b665f5
|
7
|
+
data.tar.gz: d28997562681c7028e9793fc1bad0fbdff5e27fa2194809ced10f6cc5fd9dff75d64e9e089da19259aab5a34ad68404f0a146a891e583c6e656b4d3fd02421d4
|
@@ -1,8 +1,9 @@
|
|
1
1
|
module DataStructures101
|
2
2
|
module Hash
|
3
3
|
class BaseHashTable
|
4
|
+
include Enumerable
|
4
5
|
|
5
|
-
attr_reader :size, :hash_lambda
|
6
|
+
attr_reader :size, :hash_lambda, :capacity
|
6
7
|
|
7
8
|
def initialize(capacity, prime, hash_lambda = nil)
|
8
9
|
@capacity = capacity
|
@@ -41,6 +42,14 @@ module DataStructures101
|
|
41
42
|
bucket_delete(hash_lambda.call(key), key)
|
42
43
|
end
|
43
44
|
|
45
|
+
def each
|
46
|
+
return enum_for(:each) unless block_given?
|
47
|
+
|
48
|
+
bucket_each do |key, value|
|
49
|
+
yield(key, value)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
44
53
|
private
|
45
54
|
|
46
55
|
def new_capacity()
|
@@ -28,7 +28,7 @@ module DataStructures101
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def size
|
31
|
+
def size
|
32
32
|
@table.size
|
33
33
|
end
|
34
34
|
|
@@ -47,6 +47,13 @@ module DataStructures101
|
|
47
47
|
value
|
48
48
|
end
|
49
49
|
|
50
|
+
def each
|
51
|
+
return enum_for(:each) unless block_given?
|
52
|
+
|
53
|
+
@table.each do |key, value|
|
54
|
+
yield(key, value)
|
55
|
+
end
|
56
|
+
end
|
50
57
|
end
|
51
58
|
end
|
52
59
|
end
|