singlylinkedlist

package
v0.0.0-...-118d4d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2016 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type List

type List struct {
	// contains filtered or unexported fields
}

func New

func New() *List

Instantiates a new empty list

func (*List) Add

func (list *List) Add(values ...interface{})

Appends a value (one or more) at the end of the list (same as Append())

func (*List) Append

func (list *List) Append(values ...interface{})

Appends a value (one or more) at the end of the list (same as Add())

func (*List) Clear

func (list *List) Clear()

Removes all elements from the list.

func (*List) Contains

func (list *List) Contains(values ...interface{}) bool

Check if values (one or more) are present in the set. All values have to be present in the set for the method to return true. Performance time complexity of n^2. Returns true if no arguments are passed at all, i.e. set is always super-set of empty set.

func (*List) Empty

func (list *List) Empty() bool

Returns true if list does not contain any elements.

func (*List) Get

func (list *List) Get(index int) (interface{}, bool)

Returns the element at index. Second return parameter is true if index is within bounds of the array and array is not empty, otherwise false.

func (*List) Prepend

func (list *List) Prepend(values ...interface{})

Prepends a values (or more)

func (*List) Remove

func (list *List) Remove(index int)

Removes one or more elements from the list with the supplied indices.

func (*List) Size

func (list *List) Size() int

Returns number of elements within the list.

func (*List) Sort

func (list *List) Sort(comparator utils.Comparator)

Sorts values (in-place) using timsort.

func (*List) String

func (list *List) String() string

func (*List) Swap

func (list *List) Swap(i, j int)

Swaps values of two elements at the given indices.

func (*List) Values

func (list *List) Values() []interface{}

Returns all elements in the list.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL