Method for implementing a double-ended queue in a memory arrangement
First Claim
1. A method for implementing a double-ended queue (deque) in a memory where information is stored as data units and each element is allocated its own memory space, in which method data units are added to and removed from the queue according to the LIFO or FIFO principle in such a way that data units are added to or removed from either the beginning or the end of the queue, characterised in that a three-element node is used in the memory on the highest level of hierarchy, with its one element pointing to the buffer forming the beginning of the queue, and with its other element pointing to the buffer forming the tail end of the queue. the middle of the queue is formed of nodes on successive levels of hierarchy so that a pointer contained in the third element of the three-element node on each level of hierarchy points to the next lower level of hierarchy so that the said pointer points to a node on the next lower level of hierarchy which is a similar three-element node, with the exception of the lowest level of hierarchy, where the said node can also be a buffer, and with the exception of the highest level of hierarchy, where the said buffer can also be a NIL pointer, when the two pre-determined elements of the three-element node in the middle of the queue contain a pointer to the buffer, adding elements to the queue is done to a buffer forming either the head or tail end of the queue, and when the buffer being pointed to from the elements of a three-element node becomes full, it is moved to become an element in a buffer on the next lower level of hierarchy, and removing elements from the queue is done to a buffer forming either the head or tail end of the queue, and when the buffer being pointed to from the elements of a three-element node becomes empty, a full buffer, being an element of a buffer on the next lower level of hierarchy, is fetched up from the said lower level of hierarchy to replace it.
4 Assignments
0 Petitions
Accused Products
Abstract
The invention relates to a method for implementing a double-ended queue (deque) in a memory (MEM), and to a memory arrangement. To be able to reduce the amount of copying, particularly in functional environments, the double-ended queue is used in the memory as a hierarchic data structure where on the highest level of hierarchy, there is a three-element node of whose elements one points to the buffer forming the front end of the queue and another to the buffer forming the tail end of the queue. The middle of the queue consists of nodes on different levels of hierarchy so that pointing from each level of hierarchy to the next lower level of hierarchy is done by a pointer in the third element of a three-element node. The pointer points to a node on the next lower level of hierarchy which is a similar three-element node, with the exception of the lowest level of hierarchy where the said node can also be a buffer, and with the exception of the highest level of hierarchy, where the said pointer can also be a NIL pointer. Also the pointers in the two predetermined elements of the three-element node in the middle of the queue point to buffers. In the data structure, a buffer on a given level of hierarchy is treated as an element of a buffer on the next lower level of hierarchy. Adding (removing) elements to the queue is done at the buffers forming the front or tail end of the queue. A buffer which becomes full (or empty) in connection with adding (or removing) an element, is moved from one level of hierarchy to another.
48 Citations
11 Claims
-
1. A method for implementing a double-ended queue (deque) in a memory where information is stored as data units and each element is allocated its own memory space, in which method data units are added to and removed from the queue according to the LIFO or FIFO principle in such a way that data units are added to or removed from either the beginning or the end of the queue,
characterised in that a three-element node is used in the memory on the highest level of hierarchy, with its one element pointing to the buffer forming the beginning of the queue, and with its other element pointing to the buffer forming the tail end of the queue. the middle of the queue is formed of nodes on successive levels of hierarchy so that a pointer contained in the third element of the three-element node on each level of hierarchy points to the next lower level of hierarchy so that the said pointer points to a node on the next lower level of hierarchy which is a similar three-element node, with the exception of the lowest level of hierarchy, where the said node can also be a buffer, and with the exception of the highest level of hierarchy, where the said buffer can also be a NIL pointer, when the two pre-determined elements of the three-element node in the middle of the queue contain a pointer to the buffer, adding elements to the queue is done to a buffer forming either the head or tail end of the queue, and when the buffer being pointed to from the elements of a three-element node becomes full, it is moved to become an element in a buffer on the next lower level of hierarchy, and removing elements from the queue is done to a buffer forming either the head or tail end of the queue, and when the buffer being pointed to from the elements of a three-element node becomes empty, a full buffer, being an element of a buffer on the next lower level of hierarchy, is fetched up from the said lower level of hierarchy to replace it.
-
7. A memory arrangement for implementing a double-ended queue (deque), which memory arrangement includes a data structure consisting of buffers,
characterised in that the data structure is formed of buffers on several different levels of hierarchy in such a way that the highest level of hierarchy has a three-element node whose one element points to the buffer forming the front end of the queue and whose other element points to the buffer forming the tail end of the queue, the middle of the queue consists of nodes on successive levels of hierarchy so that pointing from each level of hierarchy to the next lower level of hierarchy is done by the pointer in the third element in the three-element node so that the said pointer points to a node on the next lower level of hierarchy that is a similar three-element node, with the exception of the lowest level of hierarchy where the said node can also be a buffer, and with the exception of the highest level of hierarchy where the said pointer can also be a NIL pointer, when also two of the elements in the three-element node in the middle of the queue contain a pointer that points to a buffer, a buffer on a given level of hierarchy is treated as an element of a buffer on the next lower level of hierarchy.
Specification