DataStructures.jl
DataStructures.jl copied to clipboard
possible bug in fenwick.jl
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
,
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.
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.