简体   繁体   中英

Looking for name of a priority queue data structure based on bit-boundary buckets

I'm looking for the name of a data structure. I came up with this idea but suspect it should already be known, and don't know what to search to find it.

This priority queue is based on putting items into buckets based on the position of the largest bit that differs between the largest dequeued priority so far, and the item's priority. Its advantage, over for example a heap, is that it tends to move events in big contiguous groups instead of one by one which gives more memory locality. Note that this priority queue requires that dequeued priorities must increase monotonically. So for example it could be used for an advancing timeline of potential events, but it couldn't be used in all situations.


Suppose priorities are 32 bit integers. Then the priority queue has 33 buckets, each of which is just a vector of prioritized items where the priorities in bucket k differ from the largest dequeued priority at bit position k-1 (with "-1" meaning no difference).

To enqueue an item, append it into bucket std::bit_width(largest_dequeued_priority ^ priority_of_item) . If the item's priority is less than largest_dequeued_priority, throw a "not monotonic" exception instead of enqueueing.

To dequeue an item, find the first non-empty bucket. If there is none, fail. If the first empty bucket isn't bucket 0, then advance largest_dequeued_priority to the minimum item priority in that bucket and re-enqueue every item in the bucket to redistribute the items to lower buckets. Now pop an item out of bucket 0 and return it as the result.

在此处输入图像描述

This data structure is called a radix heap .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM