slice

package
v0.0.0-...-3a26ebd Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2019 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Slice

type Slice []interface{}

Slice is a list-like object whose methods are used to perform traversal and mutation operations.

func New

func New(values ...interface{}) *Slice

New instantiates a new empty or populated, Slice pointer. Slice pointers are mutable and hold and arguments as an interface. Any dataset retrieved from the Slice is intended to be cast to a required type. Unlike basic list-like objects, the Slice provides safe getters and setters, aiming to reduce the likelyhood of an exception being thrown during an operation.

func (*Slice) Append

func (pointer *Slice) Append(value interface{}) *Slice

Append method adds one element to the end of the Slice and returns the modified Slice.

func (*Slice) Assign

func (pointer *Slice) Assign(values ...interface{}) *Slice

Assign method adds zero or more elements to the beginning of the Slice and returns the modified Slice.

func (*Slice) Bounds

func (pointer *Slice) Bounds(i int) bool

Bounds checks an integer value safely sits within the range of accessible values for the Slice.

func (*Slice) Concatenate

func (pointer *Slice) Concatenate(slice *Slice) *Slice

Concatenate merges two Slices into a single Slice.

func (*Slice) Each

func (pointer *Slice) Each(f func(i int, value interface{})) *Slice

Each method executes a provided function once for each Slice element.

func (*Slice) Fetch

func (pointer *Slice) Fetch(i int) interface{}

Fetch retrieves the interface held at the argument index. Returns nil if index exceeds Slice length.

func (*Slice) Get

func (pointer *Slice) Get(i int) (interface{}, bool)

Get returns the interface held at the argument index and a boolean indicating if it was successfully retrieved.

func (*Slice) Join

func (pointer *Slice) Join(character string) string

Join merges all elements in the Slice into a single string.

func (*Slice) Len

func (pointer *Slice) Len() int

Len method returns the number of elements in the Slice.

func (*Slice) Less

func (pointer *Slice) Less(i, j int) bool

Less checks the string value of two elements in the slice and checks which element has the lower value.

func (*Slice) Map

func (pointer *Slice) Map(f func(i int, value interface{}) interface{}) *Slice

Map method executes a provided function once for each Slice elements and sets the returned value to the current index.

func (*Slice) Poll

func (pointer *Slice) Poll() interface{}

Poll method removes the first element from the Slice and returns that removed element. This method changes the length of the Slice.

func (*Slice) Pop

func (pointer *Slice) Pop() interface{}

Pop method removes the last element from the Slice and returns that element. This method changes the length of the array.

func (*Slice) Preassign

func (pointer *Slice) Preassign(values ...interface{}) *Slice

Preassign method adds zero or more elements to the beginning of the Slice and returns the modified Slice.

func (*Slice) Precatenate

func (pointer *Slice) Precatenate(slice *Slice) *Slice

Precatenate merges two Slices, prepending the argument Slice.

func (*Slice) Prepend

func (pointer *Slice) Prepend(value interface{}) *Slice

Prepend method adds one element to the beginning of the Slice and returns the modified Slice.

func (*Slice) Replace

func (pointer *Slice) Replace(i int, value interface{}) bool

Replace method changes the contents of the Slice at the argument index if it is in bounds.

func (*Slice) Slice

func (pointer *Slice) Slice(start, end int) *Slice

Slice method returns a shallow copy of a portion of the Slice into a new Slice type selected from begin to end (end not included). The original Slice will not be modified.

func (*Slice) Sort

func (pointer *Slice) Sort() *Slice

Sort alphabetically organises each element in the Slice.

func (*Slice) Splice

func (pointer *Slice) Splice(start, end int) *Slice

Splice method changes the contents of the Slice by removing existing elements.

func (*Slice) Swap

func (pointer *Slice) Swap(i int, j int)

Swap moves element i to j and j to i.

Jump to

Keyboard shortcuts

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