March 2019
Intermediate to advanced
336 pages
9h 9m
English
This method adds the given element to the circular queue. In the following code snippet, the Add method takes an element parameter of the interface type and adds the element to the circular queue:
// Add methodfunc (circularQueue *CircularQueue) Add(element interface{}) { if circularQueue.IsComplete() { panic("Queue is Completely Utilized") } circularQueue.nodes[circularQueue.last] = element circularQueue.last = (circularQueue.last + 1) % circularQueue.size}
The example output for the Add method is as follows. The Add method takes the element with value 1 and updates the queue:

Read now
Unlock full access