1.2.12.4.7 SRV_QUEUE_Read_Element Function

C

SRV_QUEUE_ELEMENT *SRV_QUEUE_Read_Element(
    SRV_QUEUE *queue, 
    uint16_t elementIndex
);

Summary

Reads an element from a queue at the given index.

Description

This function reads an element from a queue at the given index.

Precondition

The queue must have been initialized previously with function SRV_QUEUE_Init.

Parameters

ParamDescription
queuePointer to the queue from which the element must be read
elementIndexPosition of the element in the queue

Returns

  • Pointer to the queue element.

  • If the queue is empty, NULL is returned.

Example

#define NUM_MAX_NODES    750
typedef struct _node_info_tag
{
    struct _node_info_tag *prev;
    struct _node_info_tag *next;
    uint8_t macAddress[8]
} NODE_INFO;

static SRV_QUEUE nodeQueue;
static NODE_INFO nodeInfo1;
static NODE_INFO nodeInfo2;
NODE_INFO *nodeInfo3;

SRV_QUEUE_Init(&nodeQueue, NUM_MAX_NODES, SRV_QUEUE_TYPE_SINGLE);
memset(nodeInfo1.macAddress, 0xFF, 8);
SRV_QUEUE_Append(&nodeQueue, (SRV_QUEUE_ELEMENT *)&nodeInfo1);
memset(nodeInfo2.macAddress, 0xEE, 8);
SRV_QUEUE_Insert_After(&nodeQueue, (SRV_QUEUE_ELEMENT *)&nodeInfo1, 
                        (SRV_QUEUE_ELEMENT *)&nodeInfo2);
nodeInfo3 = SRV_QUEUE_Read_Element(&nodeQueue, 2);

Remarks

None.