-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add colony data structure #31338
Add colony data structure #31338
Conversation
#define COLONY_DESTROY(the_allocator, allocator_instance, location) std::allocator_traits<the_allocator>::destroy(allocator_instance, location) | ||
#define COLONY_ALLOCATE(the_allocator, allocator_instance, size, hint) std::allocator_traits<the_allocator>::allocate(allocator_instance, size, hint) | ||
#define COLONY_ALLOCATE_INITIALIZATION(the_allocator, size, hint) std::allocator_traits<the_allocator>::allocate(*this, size, hint) | ||
#define COLONY_DEALLOCATE(the_allocator, allocator_instance, location, size) std::allocator_traits<the_allocator>::deallocate(allocator_instance, location, size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could get rid of these now too, trying to decide if its worth the effort...
I'm in the process of porting the test suite from plf over to our catch2 testing environment. Once that is finished, this should be ready to go. |
a28ab96
to
863317e
Compare
Alright, we now have 1000 lines of test cases making sure this works as expected. I'm calling this done, barring additional code cleanup suggestions. |
- colony basics (simple insertion/erasure/iterator testing) - insert and erase - range erase - sort - insertion methods - perfect forwarding - emplace - group size and capacity - splice Delete `group_size_sum()` from colony as it is only needed for debugging
Correction to reserve() semantics. Reserve() also will no longer assert that reserve amount is within bounds of maximum and minimum group sizes, and will silently round the value down or up accordingly. Please consult the documentation to understand the current limitations of reserve() for colony.
plflib just released a small update, so I applied that too. |
Summary
SUMMARY: Infrastructure "Add colony data structure."
Purpose of change
The intent is to used this data structure to replace how we store items on the map.
There are several issues with using our current data structure of an
std::list
. In particular, removal of elements from the "middle" of the list invalidates references and iterators to elements after the one removed. This makes the item management code convoluted, and in some cases severely technically limited.Describe the solution
Introduce a new data structure,
colony
that has the following major advantages overstd::list
:You can read about all the details and more about the justification here: https://www.plflib.org/colony.htm
This implementation is taken directly from https://github.com/mattreecebentley/plf_colony and modified to fit into our code better
This pull request does not yet reimplement
item_stack
using a colony, that will come in a subsequent PR. I just wanted to get the data structure/implementation itself up for formal review.Additional context
I'm not quite done with this, I intend to remove the preprocessor directives for supporting older c++ compilers/versions than we support to further clean up the code.
Also, it would be probably be polite to acknowledge that we are using a modified version of the PLF implementation somewhere in the project documentation, but I wasn't sure where best to put this. Will defer to @kevingranade on that.