JuliaCollections / JuliaCollections/DataStructures.jl

Separate Error struct for heaps Bound Error

Open
#598 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Currently for bounds error in heaps , array bounds error is used as

julia> x = MutableBinaryMinHeap{Int}()
MutableBinaryHeap()
julia> push!(x,10)
1
julia> delete!(x,2)
ERROR: BoundsError: attempt to access 1-element Array{Int32,1} at index [2]
Stacktrace:
 [1] getindex at ./array.jl:731 [inlined]
 [2] delete!(::MutableBinaryHeap{Int32,DataStructures.LessThan}, ::Int32) at /home/kps/DataStructures.jl/src/heaps/mutable_binary_heap.jl:271
 [3] top-level scope at none:0

Instead BoundsError for heaps to be displayed as

ERROR: HeapBoundsError: attempt to access 1-element MutableBinaryMinheap{Int32} at index [2]

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 in src/heaps/mutable_binary_heap.jl, especially the delete! path shown in the stack trace, and inspect how bounds errors are currently produced. Check nearby heap tests for bounds-error coverage. Done means heap out-of-range access reports the proposed HeapBoundsError wording rather than the generic array BoundsError.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.