delete! works lazily?
Indigo2233 opened this issue · 1 comments
Indigo2233 commented
I would like to implement LRUCache by OrderedDict. However, it showed me
julia> a = OrderedDict{Int, Int}(1 => 1, 2=>2)
OrderedDict{Int64, Int64} with 2 entries:
1 => 1
2 => 2
julia> delete!(a, 2);
julia> a.keys
2-element Vector{Int64}:
1
2
julia> a
OrderedDict{Int64, Int64} with 1 entry:
1 => 1
julia> a.keys
1-element Vector{Int64}:
1
oxinabox commented
Field's of a struct are private unless documented otherwise.
If you want to know the keys use keys(a)
.
I suspect we are indeed lazy. and they stay around while a.dirty==true
, which IIRC stays around til rehash!
gets called.
Which will happen automatically at "appropriate" times