Several Zig data structures in the standard library have "unmanaged" types that require the user to pass an allocator to any function that may allocate. Examples include ArrayListUnmanaged and HashMapUnmanaged. There is however no such type for PriorityQueue.
I'm currently in need of a PriorityQueueUnmanaged, and I made one myself from the existing PriorityQueue code. I'd be happy to contribute it to the standard library if the contribution would be welcome.
The main questions I'd have for an acceptable implementation would be:
- Whether the original PriorityQueue type should be implemented in terms of the new PriorityQueueUnmanaged type. ArrayList seems to have separate implementations rather than having the managed version rely on the unmanaged version and I'm not sure why without reading it more closely. My inclination would be to implement PriorityQueue in terms of PriorityQueueUnmanaged but I'm curious whether others see drawbacks to this approach that I'm not seeing.
- Whether there should only be a PriorityQueueUnmanaged type, or whether the base type should be PriorityQueueAlignedUnmanaged similar to ArrayList. I have not done it with AlignedUnmanaged locally but given the backing data is just stored in a slice, I think an AlignedUnmanaged type would make sense.
Several Zig data structures in the standard library have "unmanaged" types that require the user to pass an allocator to any function that may allocate. Examples include ArrayListUnmanaged and HashMapUnmanaged. There is however no such type for PriorityQueue.
I'm currently in need of a PriorityQueueUnmanaged, and I made one myself from the existing PriorityQueue code. I'd be happy to contribute it to the standard library if the contribution would be welcome.
The main questions I'd have for an acceptable implementation would be: