A data structure for efficient enqueuing and dequeuing is disclosed. The
structure includes a horizontally linked list, an array, a vertically
linked list, and a head pointer. Entity ranks are distributed over the
array, where each array entry has a range of ranks. Each array entry
points to null or the entity having the greatest rank within that entry's
range. The horizontally linked list links at least a subset of ranked
entities. Each entity in the linked list has a unique rank as compared to
the ranks of the other entities in the list. Each vertically linked list
links a subset of entities having an identical rank. The head pointer
points to the entity that has the greatest rank. Methods for adding
entities to and removing entities from the data structure are also
disclosed. The invention can be used to enqueue threads to and dequeue
threads from a priority queue.