OrderedSet indexing

Any idea why OrderedSet indexing is deprecated? If I follow the recommendation then I would have to keep a counter and iterate until I find the ith item?

julia> using DataStructures

julia> os = OrderedSet([2,3,1,4,7,6])
OrderedSet{Int64}([2, 3, 1, 4, 7, 6])

julia> os[2]
┌ Warning: indexing is deprecated for OrderedSet, please rewrite your code to use iteration
│   caller = top-level scope at none:0
└ @ Core none:0

If you try

@edit os[2]

it will take you to the relevant method, above which you find a reference to


which explains the reason.

In case the code did not have a comment like this, use the Github “blame” functionality on source files:


to find the PR/commit that changed something.

1 Like


And, I agree with this comment :slight_smile: