GO basis of the List

A, List definitions

Summary
1, list is a non-continuous storage container, a plurality of nodes, the node records the relationship between each other by a number of variables. list a variety of implementations, such as one-way linked list, a doubly linked list and so on.
2. The principle Go language list is doubly linked list. list element can be efficiently performed anywhere insert and delete operations

go in the list

  • Golan standard library provides advanced data structures List. In particular package container / ist.
  • container / ist package there are two main types of data structures: "Element", "List";
  • Element element types represent a doubly linked list, corresponding to the inside of the C ++ "iterator";
  • List represents a doubly linked list. List of zero is an empty, available list.
  • Element has Prev and Next methods for obtaining the previous and next Element, Element Value property can call directly;

Two, list of use

1, by a method declaration New container / list package list

  • • variable name: = list.New ()

2, through var declaration list

  • • var variable name list.List
  • • list with a slice and map different, no specific element type of restriction. elements of the list can be of any type.
  • • Inside the CPP, members of the list must be the same data type, but the language does allow list Go insert any type of member.
  • • We recommend using New () implementation declaration list

 

Guess you like

Origin www.cnblogs.com/jalja/p/11785534.html