INNER CODE UNIT · C++
Hit_list
torognes/swarm · src/algod1.cpp:76
class Hit_list {
public:
explicit Hit_list(std::vector<unsigned int> & storage) noexcept
: storage_(storage) {}
/* room for 'additional' more hits, grown in whole chunks. used_ is a
std::size_t, the same type as storage_.size(), so the sum below
cannot wrap; as an unsigned int count it could, skipping the growth
and leaving push() to write out of bounds. */
auto reserve_for(std::size_t const additional) -> void {
auto const required = used_ + additional;
if (required <= storage().size()) { return; }
auto enlarged = storage().size();
while (required > enlarged) {
enlarged += hit_chunk;
}
storage().resize(enlarged);
}