Accessing queue data
AssigneeHangzhou DPtech Technologies Co., Ltd.
InventorTian Tan
Life of this patent
Estimating the term…
Abstract
A method and apparatus of accessing queue data is provided. According to the method, a double-layer circular queue is constructed, where the double-layer circular queue includes one or more inner-layer circular queues established based on an array, and the one or more inner-layer circular queues constitute an outer-layer circular queue of the double-layer circular queue based on a linked list. A management pointer of the outer-layer circular queue is set. Data accessing is performed on the inner-layer circular queues by using the management pointer.
Claims12
A method of accessing queue data, comprising:
- constructing a double-layer circular queue, wherein the double-layer circular queue comprises one or more inner-layer circular queues established in an array manner, and the one or more inner-layer circular queues constitute an outer-layer circular queue of the double-layer circular queue in a linked list manner;
- setting a management pointer for the outer-layer circular queue;
- and
- performing data accessing on the inner-layer circular queues based on the management pointer,
- wherein said setting the management pointer for the outer-layer circular queue comprises:
- setting a FIRST pointer and a LAST pointer for the outer-layer circular queue, wherein the FIRST pointer points to a first node of the outer-layer circular queue and the inner-layer circular queue corresponding to the first node is non-empty;
- the LAST pointer points to a last node of the outer-layer circular queue and the inner-layer circular queue corresponding to the last node is non-empty;
- said performing data accessing on the inner-layer circular queues based on the management pointer comprises:
- storing data in a memory block corresponding to the inner-layer circular queue based on a space state of the inner-layer circular queue of a node pointed by the management pointer,
- wherein said storing data in the memory block corresponding to the inner-layer circular queue based on the space state of the inner-layer circular queue of the node pointed by the management pointer comprises:
- determining whether there is an idle memory space in the inner-layer circular queue corresponding to the node pointed by the LAST pointer of the outer-layer circular queue;
- determining whether there is a node after the node pointed by the LAST pointer of the outer-layer circular queue when there is no idle memory space;
- when determining that there is a node,
- pointing the LAST pointer of the outer-layer circular queue to the node after the node pointed by the LAST pointer;
- when determining that there is no node,
- establishing an inner-layer circular queue as a new node and adding the new node into the outer-layer circular queue, and pointing the LAST pointer of the outer-layer circular queue to the new node;
- and
- storing data into the inner-layer circular queue corresponding to the node pointed by the LAST pointer of the outer-layer circular queue.
An apparatus for accessing queue data, comprising:
- a processor;
- and
- a non-transitory storage medium storing machine-executable instructions, wherein by reading and executing the machine executable instructions, the processor is caused to:
- construct a double-layer circular queue, wherein the double-layer circular queue comprises one or more inner-layer circular queues established in an array manner, and the one or more inner-layer circular queues constitute an outer-layer circular queue of the double-layer circular queue in a linked list manner;
- set a management pointer for the outer-layer circular queue;
- and
- perform data accessing on the inner-layer circular queues based on the management pointer,
- wherein when the management pointer for the outer-layer circular queue is set, the processor is further caused by the machine executable instructions to:
- set a FIRST pointer and a LAST pointer for the outer-layer circular queue, wherein the FIRST pointer points to a first node of the outer-layer circular queue and the inner-layer circular queue corresponding to the first node is non-empty;
- the LAST pointer points to a last node of the outer-layer circular queue and the inner-layer circular queue corresponding to the last node is non-empty;
- when data accessing is performed on the inner-layer circular queues based on the management pointer, the processor is further caused by the machine executable instructions to:
- store data in a memory block corresponding to the inner-layer circular queue based on a space state of the inner-layer circular queue of a node pointed by the management pointer,
- wherein when data is stored in the memory block corresponding to the inner-layer circular queue based on the space state of the inner-layer circular queue of the node pointed by the management pointer, the processor is further caused by the machine executable instructions to:
- determine whether there is an idle memory space in the inner-layer circular queue corresponding to the node pointed by the LAST pointer of the outer-layer circular queue;
- determine whether there is a node after the node pointed by the LAST pointer of the outer-layer circular queue when there is no idle memory space;
- when determining that there is a node,
- point the LAST pointer of the outer-layer circular queue to the node after the node pointed by the LAST pointer;
- when determining that there is no node,
- establish an inner-layer circular queue as a new node and add the new node into the outer-layer circular queue, and point the LAST pointer of the outer-layer circular queue to the new node;
- and
- store data into the inner-layer circular queue corresponding to the node pointed by the LAST pointer of the outer-layer circular queue.
Dependencies are inferred from the claim text.