Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve MutableLinkedList for 1.0 #873

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/src/mutable_linked_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Usage:
l = MutableLinkedList{T}() # initialize an empty list of type T
l = MutableLinkedList{T}(elts...) # initialize a list with elements of type T
isempty(l) # test whether list is empty
empty!(l) # empties the list
length(l) # get the number of elements in list
collect(l) # return a vector consisting of list elements
eltype(l) # return type of list
Expand All @@ -18,19 +19,23 @@ last(l) # return value of last element of list
l1 == l2 # test lists for equality
map(f, l) # return list with f applied to elements
filter(f, l) # return list of elements where f(el) == true
filter!(f, l) # mutating version of `filter(f,l)`
reverse(l) # return reversed list
reverse!(l) # reverse the list in place
copy(l) # return a copy of list
getindex(l, idx) || l[idx] # get value at index
getindex(l, range) || l[range] # get values within range a:b
setindex!(l, data, idx) # set value at index to data
append!(l1, l2) # attach l2 at the end of l1
append!(l, elts...) # attach elements at end of list
append!(l, collections...) # all elements of all collections to l
prepend(l, collections...) # add all elements of all collections in front of l
delete!(l, idx) # delete element at index
delete!(l, range) # delete elements within range a:b
push!(l, data) # add element to end of list
pushfirst!(l, data) # add element to beginning of list
pop!(l) # remove element from end of list
popfirst!(l) # remove element from beginning of list
splice!(l,idx,ins) # remove element given as `idx` and insert elements of `ins` instead. idx is either an Int or a UnitRange

```

`MutableLinkedList` implements the Iterator interface, iterating over the list
Expand Down
12 changes: 12 additions & 0 deletions src/deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ Base.@deprecate_binding IntDisjointSets IntDisjointSet
@deprecate insert!(m::SortedDict, k, d) push_return_semitoken!(m::SortedDict, k=>d)
@deprecate insert!(m::SortedMultiDict, k, d) (push_return_semitoken!(m::SortedMultiDict, k=>d))[2]

function Base.delete!(l::MutableLinkedList, idx)
Expr(:meta, :noinline)
Base.depwarn("`delete!(l::MutableLinkedList,idx::Int)` is deprecated, use `deleteat!(l,idx)` instead.", :delete!)
deleteat!(l,idx)
end

function Base.delete!(l::MutableLinkedList, r::UnitRange)
Expr(:meta, :noinline)
Base.depwarn("`delete!(l::MutableLinkedList,r::UnitRange)` is deprecated, use `deleteat!(l,idx)` instead.", :delete!)
deleteat!(l,r)
end
Comment on lines +26 to +36
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't this be done with the @deprecate macro?


function Base.peek(q::PriorityQueue)
Expr(:meta, :noinline)
Base.depwarn("`peek(q::PriorityQueue)` is deprecated, use `first(q)` instead.", :peek)
Expand Down
Loading
Loading