Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrorEmptyList = errors.New("a list is empty")
)
Functions ¶
This section is empty.
Types ¶
type LinkedList ¶
type LinkedList struct {
// contains filtered or unexported fields
}
LinkedList is a struct that has pointers to the first and last nodes and also size of a list.
func NewLinkedList ¶
func NewLinkedList() *LinkedList
NewLinkedList builds an empty linked list and returns its pointer.
func (*LinkedList) Append ¶
func (l *LinkedList) Append(value interface{})
Append adds an element to the end of a list.
func (*LinkedList) Count ¶
func (l *LinkedList) Count(value interface{}) int
Count returns a number of times a given value is occurred in a list.
func (*LinkedList) PeekFirst ¶
func (l *LinkedList) PeekFirst() (interface{}, error)
PeekFirst takes first element of a list. If a list is empty returns an error.
func (*LinkedList) PeekLast ¶
func (l *LinkedList) PeekLast() (interface{}, error)
PeekLast takes last element of a list. If a list is empty returns an error.
func (*LinkedList) Prepend ¶
func (l *LinkedList) Prepend(value interface{})
Prepend adds an element to the front of a list.
func (*LinkedList) Size ¶
func (l *LinkedList) Size() int
Size returns the number of nodes in a list.
Click to show internal directories.
Click to hide internal directories.