DataStructures.jl icon indicating copy to clipboard operation
DataStructures.jl copied to clipboard

possible bug in fenwick.jl

Open StephenVavasis opened this issue 2 years ago • 2 comments

There is a big discussion (https://discourse.julialang.org/t/offsetarrays-inbounds-and-confusion/81295) on discourse about why it is a bad idea to iterate over an AbstractVector, say a, using for i=1:length(a) (because this will fail if a is an OffsetArray). I checked the src file for DataStructures and found this style of code in fenwick.jl.

Update: this issue is also present in: append! for circular buffer and nextreme in heaps.jl,

StephenVavasis avatar May 21 '22 02:05 StephenVavasis

As much as I don't think that Fenwick is suitable in DataStructures.jl, part of the mechanism that makes Fenwick Trees fast is to exploit the contiguous small indexing range of 1...N or 0...N depending on the implementation. Hence, this is not really a suitable change for Fenwick Trees.

SyxP avatar May 22 '22 14:05 SyxP

OK, so then maybe the offending constructor in Fenwick should take a Vector instead of an AbstractVector?

Btw, should I split this issue into three separate issues, one for fenwick, one for circular buffer, and one for heaps? I'm not sure who is maintaining those codes.

StephenVavasis avatar May 22 '22 15:05 StephenVavasis