Skip to content

Commit

Permalink
update for 1.0 (#10)
Browse files Browse the repository at this point in the history
* update for 1.0

* iteration interface
  • Loading branch information
simonbyrne authored and quinnj committed Aug 29, 2018
1 parent a0ab9fa commit e2f2e3d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ os:
- osx
julia:
- 0.7
- 1.0
- nightly
notifications:
email: false
Expand Down
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
julia 0.7-alpha
julia 0.7
7 changes: 3 additions & 4 deletions src/LRUCache.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ LRU(m::Int=__MAXCACHE__) = LRU{Any, Any}(m)

Base.show(io::IO, lru::LRU{K, V}) where {K, V} = print(io,"LRU{$K, $V}($(lru.maxsize))")

Base.start(lru::LRU) = start(lru.ht)
Base.next(lru::LRU, state) = next(lru.ht, state)
Base.done(lru::LRU, state) = done(lru.ht, state)
Base.iterate(lru::LRU) = iterate(lru.ht)
Base.iterate(lru::LRU, state) = iterate(lru.ht, state)

Base.length(lru::LRU) = length(lru.q)
Base.isempty(lru::LRU) = isempty(lru.q)
Expand Down Expand Up @@ -82,7 +81,7 @@ function Base.setindex!(lru::LRU{K, V}, v, key) where {K, V}
lru.ht[key] = item
else
item = LRUNode{K, V}(key, v)
unshift!(lru.q, item)
pushfirst!(lru.q, item)
lru.ht[key] = item
end
return lru
Expand Down
4 changes: 2 additions & 2 deletions src/list.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function Base.pop!(l::LRUList{K, V}, n::LRUNode{K, V}=last(l)) where {K, V}
return n
end

function Base.unshift!(l::LRUList{K, V}, el::LRUNode{K, V}) where {K, V}
function Base.pushfirst!(l::LRUList{K, V}, el::LRUNode{K, V}) where {K, V}
push!(l, el)
rotate!(l)
end
Expand All @@ -102,7 +102,7 @@ end
function move_to_front!(l::LRUList{T}, n::LRUNode{T}) where {T}
if first(l) !== n
pop!(l, n)
unshift!(l, n)
pushfirst!(l, n)
end
return l
end
Expand Down

0 comments on commit e2f2e3d

Please sign in to comment.