Skip to content

last for OrderedDict/KeyIterator/ValueIterator #99

Closed
@oxinabox

Description

@oxinabox

first works on all of these, but last doesn't

julia> dd =  OrderedDict(1=>2, 3=>4)
OrderedDict{Int64, Int64} with 2 entries:
  1 => 2
  3 => 4

julia> first(dd)
1 => 2

julia> last(dd)
ERROR: MethodError: no method matching lastindex(::OrderedDict{Int64, Int64})
...

But you can get them via:

julia> last(dd.keys)
3

julia> last(dd.vals)
4

But that is going in to the internals.

This should be a nice easy PR.
Just need to dispatch on Base.ValueIterator{OrderedDict{<:Any, <:Any}} (similar for the KeysIterator) and look at the backing dict, and then look at it's dict.vals (similarly dict.keys)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions