March 2019
Intermediate to advanced
336 pages
9h 9m
English
The NewQueue method creates a new instance of the circular queue. The NewQueue function takes the num parameter, which is the size of the queue. The function returns the circular queue of nodes, as shown in the following code:
// NewCircularQueue methodfunc NewQueue(num int) *CircularQueue { var circularQueue CircularQueue circularQueue = CircularQueue{size: num + 1, head: 0, last: 0} circularQueue.nodes = make([]interface{}, circularQueue.size) return &circularQueue}
Read now
Unlock full access