InPlace. SparseSet
(inplace v0.7.6)
Copy Markdown
Sparse set implementation based on https://youtu.be/PUJ_XdmSDZw?si=41ySCBvOdoNCV-zR
The main purpose is to support delete/undo operations on the set, so we can use it for backtracking.
NOTE: The code is intentionally kept close to the material in above video, even if it may not adhere to a conventional Elixir style.
The set is a permutation on 1..domain_size. Note: it's different from Knuth's implementation, where the set values are 0-based.
Options: :mapper - function of arity 2. Allows to associate elements of the set with values.
Summary
Functions
Iterate over set positions in increasing order (as opposed to iterating over set values).
This is equivalent to:
iterate(set, initial, redicer)
, but the above will process set elements in arbitrary order.
The intent is to not having to sort the result of the iteration.
This may or may not be more effective than the plain iteration.
Functions
Iterate over set positions in increasing order (as opposed to iterating over set values).
This is equivalent to:
iterate(set, initial, redicer)
, but the above will process set elements in arbitrary order.
The intent is to not having to sort the result of the iteration.
This may or may not be more effective than the plain iteration.