March 2019
Intermediate to advanced
336 pages
9h 9m
English
A circular linked list is a data structure in which the last node is followed by the first node. The container/ring structures are used to model circular linked lists. An example implementation of a circular linked list is shown as follows:
package mainimport ( "container/ring" "fmt")func main() { var integers []int integers = []int{1,3,5,7} var circular_list *ring.Ring circular_list= ring.New(len(integers)) var i int for i = 0; i < circular_list.Len(); i++ { circular_list.Value = integers[i] circular_list = circular_list.Next() }
The ring.New method with the len n as a parameter creates a circular list of length n. The circular linked list is initialized with an integer array by moving through circular_list with the ...
Read now
Unlock full access