d_ary_addressable_int_heap: Add push_without_update, make clear linear in size #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes the clear method linear in the size of the heap and adds a new method for adding elements without updating the heap. The use case is that I want to re-use a single heap several times as the keys are significantly larger than the size of the heap. Between the uses, I clear the heap and this should be linear in the number of remaining elements. I recognize that a simple linear fill is faster than random writes. Therefore, this only uses the random writes if we do not touch all cache lines with the random writes even if every write is on a separate cache line. I have not compared the performance and I'm also open to other suggestions. For adding new elements after the clear, I added the
push_without_update
method. It is very similar to thebuild_heap
methods, just that it allows adding elements one-by-one and one has to callupdate_all
(orclear
) at the end. I have kept the update of the handles even though it is not strictly necessary as this ensures thatcontains
can be used in betweenpush_without_update
calls. I have not added apush_without_update
method that moves the key as the documentation states thatkey_type
"has to be an unsigned integer type" and I cannot imagine that moving unsigned integers has any advantage over a pass by value or pass by reference.