-
Notifications
You must be signed in to change notification settings - Fork 0
Functions
Akshay Mohan edited this page Jan 13, 2019
·
3 revisions
Below are the functions that are used to perform enqueue operation in a queue. Both linear and circular queue share the same functions for insertion and deletion except for queue_force_enqueue.
-
Description:
- Inserts given element to the queue.
-
Parameters:
-
Queue[]- Queue on which value is to be inserted. -
value- Value to be inserted.
-
-
Return value:
-
-1- On failure | Full in case of circular queue; Rear position won't go any further in case of a linear queue. - The
rear-mostposition of the queue (ie; values>= 0).
-
-
Alias:
queue_insertqueue_add
-
Example:
new Queue:test<10>;
queue_enqueue(test, 1);
queue_insert(test, 3);
queue_add(test, 10);
-
Description:
- Forcefully inserts given element to the queue. Function overwrites existing element if the queue is full.
- This function can be used only for circular queues.
-
Parameters:
-
Queue[]- Circular queue on which value has to be inserted forcefully. -
value- Value to be inserted.
-
-
Return value:
- The
rear-mostposition of the queue.
- The
-
Alias:
queue_force_insertqueue_force_add
-
Example:
new QueueC:newsQueue<MAX_MESSAGES>;
queue_force_enqueue(newsQueue, news_id);
work-in-progress