The container package

In this section, I will explain the use of the container standard Go package. The container package supports three data structures: a heap, list, and ring. These data structures are implemented in container/heap, container/list, and container/ring, respectively.

For those of you who are unfamiliar with rings, a ring is a circular list, which means that the last element of a ring points to its first element. In essence, this means that all of the nodes of a ring are equivalent and that a ring does not have a beginning and an end. As a result, each element of a ring can help you traverse the entire ring.

The next three subsections will illustrate each one of the packages contained in the container package. The rational advice is that if the functionality of the container standard Go package suits your needs, use it; otherwise, you should implement and use your own data structures.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.103.183