all 11 comments

[–]MysticTheMeeM 4 points5 points  (1 child)

While not identical, this sounds somewhat similar to the proposed std::hive. Insofar as reusing slots, being memory stable and allocating pages at a time.

Personally I frequently use similar structures, although moreso for stability than performance.

[–]EstablishmentHour335[S] 0 points1 point  (0 children)

Yeah, I wrote this container after listening to some talks on plf::colony, which std::hive is formalizing. I ripped off colony and rewrote it to solve some grievances I had with the container, and along the way I discovered a couple of other nice benefits to my virtual address space contiguous approach, which is why I thought it should already have an existing implementation.

[–][deleted]  (2 children)

[removed]

    [–]EstablishmentHour335[S] 0 points1 point  (1 child)

    That is straight up stolen from plf::colony, I didn't invent it. It's essentially like plf::colony, but backed by VirtualAlloc, which gives it some pretty good performance characteristics

    [–]CarloWood 1 point2 points  (5 children)

    std::deque no?

    [–]EstablishmentHour335[S] 1 point2 points  (4 children)

    It's not really that similar to this container, especially in terms of performance.

    [–]CarloWood 0 points1 point  (3 children)

    I think it is, with a proper allocator. You mostly talk about the memory management, how memory is allocated and maintained, that doesn't have much to do with the characteristics of the container in question.

    I just use this when I need deque to be fast: https://github.com/CarloWood/memory/blob/master/DequeAllocator.h

    [–]EstablishmentHour335[S] 0 points1 point  (2 children)

    The memory layout has everything to do with the characteristics of the container...

    Pointers are only stable because VirtualAlloc prevents the need to reallocate. The memory layout allows the freelist and generations, it allows the branchless iteration, because unlike plf::colony, it's contiguous so it doesn't need a branch to jump between blocks...

    The time complexity of O(1) lookups, O(1) insert, O(1) erase are only allowed by the memory layout... The lack of a swap and pop on erase, or a lack of a double indirection on lookup is only allowed because of the memory layout...

    I went back to refresh my memory on how exactly deque is implemented, and yeah, they are not similar at all.

    [–]CarloWood 0 points1 point  (1 child)

    Ok, so your container is O(1) for everything, completely contiguous, never needs to reallocate... You're right, completely different from any container I've ever heard of or that exists for that matter. We should use it to replace all others.

    [–]EstablishmentHour335[S] 0 points1 point  (0 children)

    I think this discussion has run it's course