Skip to content

Commit b9aa7ca

Browse files
committed
rebase to master, and apply code review suggestions
1 parent 8535e41 commit b9aa7ca

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

src/ordered_robin_dict.jl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ end
8383

8484
empty(d::OrderedRobinDict{K,V}) where {K,V} = OrderedRobinDict{K,V}()
8585

86-
length(d::OrderedRobinDict) = d.count
87-
isempty(d::OrderedRobinDict) = (length(d) == 0)
86+
length(d::Union{RobinDict, OrderedRobinDict}) = d.count
87+
isempty(d::Union{RobinDict, OrderedRobinDict}) = (length(d) == 0)
8888

8989
"""
9090
empty!(collection) -> collection
@@ -123,7 +123,7 @@ end
123123

124124
function setindex!(h::OrderedRobinDict{K, V}, v0, key0) where {K,V}
125125
key = convert(K,key0)
126-
v = convert(V, v0)
126+
v = convert(V, v0)
127127
index = get(h.dict, key, -2)
128128

129129
if index < 0
@@ -212,10 +212,9 @@ OrderedRobinDict{String,Int64} with 4 entries:
212212
get!(collection, key, default)
213213

214214
function get!(h::OrderedRobinDict{K,V}, key0, default) where {K,V}
215-
key = convert(K,key0)
216215
index = get(h.dict, key, -2)
217216
index > 0 && return h.vals[index]
218-
v = convert(V, default)
217+
v = convert(V, default)
219218
setindex!(h, v, key)
220219
return v
221220
end
@@ -237,11 +236,10 @@ end
237236
get!(f::Function, collection, key)
238237

239238
function get!(default::Base.Callable, h::OrderedRobinDict{K,V}, key0) where {K,V}
240-
key = convert(K,key0)
241239
index = get(h.dict, key, -2)
242240
index > 0 && return @inbounds h.vals[index]
243241

244-
v = convert(V, default())
242+
v = convert(V, default())
245243
setindex!(h, v, key)
246244
return v
247245
end
@@ -455,7 +453,7 @@ Base.@propagate_inbounds function iterate(h::OrderedRobinDict, i)
455453
return (Pair(h.keys[index], h.vals[index]), index+1)
456454
end
457455

458-
filter!(f, d::OrderedRobinDict) = Base.filter_in_one_pass!(f, d)
456+
filter!(f, d::Union{RobinDict, OrderedRobinDict}) = Base.filter_in_one_pass!(f, d)
459457

460458
function merge(d::OrderedRobinDict, others::AbstractDict...)
461459
K,V = _merge_kvtypes(d, others...)

src/robin_dict.jl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,6 @@ function _setindex!(h::RobinDict{K,V}, key::K, v0) where {K, V}
251251
return h
252252
end
253253

254-
isempty(d::RobinDict) = (d.count == 0)
255-
length(d::RobinDict) = d.count
256-
257254
"""
258255
empty!(collection) -> collection
259256
@@ -591,8 +588,6 @@ Base.@propagate_inbounds function iterate(t::RobinDict)
591588
end
592589
Base.@propagate_inbounds iterate(t::RobinDict, i) = _iterate(t, get_next_filled(t, i))
593590

594-
filter!(f, d::RobinDict) = Base.filter_in_one_pass!(f, d)
595-
596591
function _merge_kvtypes(d, others...)
597592
K, V = keytype(d), valtype(d)
598593
for other in others

0 commit comments

Comments
 (0)