JuliaCollections / JuliaCollections/DataStructures.jl

Support `pushfirst!` and `popfirst!` for ordered collections

Open
#403 3 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
745
Forks
261
PR merge metrics
No merged PRs in 30d

Description

It would be nice to have these for OrderedDict and OrderedSet. At the moment in Julia 0.7:

julia> using DataStructures

julia> o = OrderedSet([1,2,3])
OrderedSet{Int64}([1, 2, 3])

julia> push!(o, 4)
OrderedSet{Int64}([1, 2, 3, 4])

julia> pop!(o, 4)
4

julia> pushfirst!(o, 0)
ERROR: MethodError: no method matching pushfirst!(::OrderedSet{Int64}, ::Int64)
Closest candidates are:
  pushfirst!(::Any, ::Any, ::Any) at abstractarray.jl:2040
  pushfirst!(::Any, ::Any, ::Any, ::Any...) at abstractarray.jl:2041
  pushfirst!(::Array{T,1}, ::Any) where T at array.jl:1063
  ...
Stacktrace:
 [1] top-level scope at none:0

julia> popfirst!(o)
ERROR: MethodError: no method matching popfirst!(::OrderedSet{Int64})
Closest candidates are:
  popfirst!(::DataStructures.IntSet) at /Users/omus/.julia/packages/DataStructures/eUHI/src/int_set.jl:90
  popfirst!(::BitSet) at bitset.jl:255
  popfirst!(::BitArray{1}) at bitarray.jl:817
  ...
Stacktrace:
 [1] top-level scope at none:0

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the OrderedDict and OrderedSet implementations and reviewing their existing push! and pop! methods. Check Julia's pushfirst! and popfirst! behavior for ordered collections, then verify that both types support the requested operations with the ordering shown in the issue examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.