Skip to content

Work buffers for algorithms? #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gdalle opened this issue Nov 21, 2024 · 1 comment
Open

Work buffers for algorithms? #410

gdalle opened this issue Nov 21, 2024 · 1 comment

Comments

@gdalle
Copy link
Member

gdalle commented Nov 21, 2024

See the discussion in #407

@rafaqz
Copy link

rafaqz commented Apr 5, 2025

I like how Base.sort has sort! for in-place methods but also has a scratch keyword for the scratch space that some sorts like radix sort needs. Graphs could do something like that.

https://github.com/JuliaLang/julia/blob/75d5588d46bf7445626837f05e7a284ad85c7d30/base/sort.jl#L1730-L1739

And a helper method make_scratch:

  │    •  Base.Sort.make_scratch

  make_scratch(scratch::Union{Nothing, Vector}, T::Type, len::Integer)

  Returns (s, t) where t is an AbstractVector of type T with length at least len that is backed by the Vector s. If scratch !==
  nothing, then s === scratch.

  This function will allocate a new vector if scratch === nothing, resize! scratch if it is too short, and reinterpret scratch if its   
  eltype is not T.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants