Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MyLinkedList ¶
type MyLinkedList struct {
// contains filtered or unexported fields
}
MyLinkedList is my implementation of the linked list.
func (*MyLinkedList) AddAtHead ¶
func (l *MyLinkedList) AddAtHead(val int)
AddAtHead add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list.
func (*MyLinkedList) AddAtIndex ¶
func (l *MyLinkedList) AddAtIndex(index int, val int)
AddAtIndex add a node of value val before the index-th node in the linked list. If index equals to the length of linked list, the node will be appended to the end of linked list. If index is greater than the length, the node will not be inserted.
func (*MyLinkedList) AddAtTail ¶
func (l *MyLinkedList) AddAtTail(val int)
AddAtTail append a node of value val to the last element of the linked list.
func (*MyLinkedList) DeleteAtIndex ¶
func (l *MyLinkedList) DeleteAtIndex(index int)
DeleteAtIndex delete the index-th node in the linked list, if the index is valid.
func (*MyLinkedList) Get ¶
func (l *MyLinkedList) Get(index int) int
Get get the value of the index-th node in the linked list. If the index is invalid, return -1.