Skip to content

Feature Request: steal backing array in flat map/set #22

Open
@yonik

Description

One feature that would greatly decrease peak memory usage in my use-case is to have the ability to "steal" the backing array from the flat-maps (after compacting them into a "normal" array first of course.)

The use-case is currently implemented as follows:

  1. add / update many objects in a flat_hash_set
  2. allocate a new array, iterate over the flat_hash_set, adding all to the array
  3. delete the flat_hash_set
  4. sort the array of objects

Perhaps something along the lines of:

// Removes and returns an array of all entries in the set.  Optimized implementations may re-use an internal array, thus
// lowering memory usage.  Only the first size() entries are defined.  It is the callers responsibility to delete the returned array.
value_type* remove_all_entries()

Oh, and thank you for the inspired lazy_emplace()! It's still more powerful than other map/set implementations of try_emplace since key creation can be deferred or customized as well.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions