glist

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

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

Go to latest
Published: May 19, 2024 License: MIT Imports: 3 Imported by: 2

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
}

List then list container

func New

func New() *List

New returns a new *List object

func (*List) Add

func (s *List) Add(v ...interface{})

Add adds a value to end of list s.

func (*List) AddFront

func (s *List) AddFront(v interface{})

AddFront adds a value to first of list s.

func (*List) CartesianProduct

func (s *List) CartesianProduct(sets ...*List) [][]interface{}

CartesianProduct → {(x, y) | ∀ x ∈ s1, ∀ y ∈ s2} For example:

		CartesianProduct(A, B), where A = {1, 2} and B = {7, 8}
       => {(1, 7), (1, 8), (2, 7), (2, 8)}

func (*List) Clear

func (s *List) Clear()

Clear empty the list s.

func (*List) Clone

func (s *List) Clone() *List

Clone duplicates the list s.

func (*List) CloneAndClear

func (s *List) CloneAndClear() *List

CloneAndClear duplicates the list s and clear s.

func (*List) Contains

func (s *List) Contains(v interface{}) bool

Contains indicates if the list contains an element.

func (*List) Get

func (s *List) Get(idx int) interface{}

Get gets a value on idx in list s.

func (*List) IndexOf

func (s *List) IndexOf(v interface{}) int

IndexOf indicates the first index of value in list s, if not found returns -1.

idx start with 0.

func (*List) IsEmpty

func (s *List) IsEmpty() bool

IsEmpty indicates if the list is empty.

func (*List) Len

func (s *List) Len() int

Len returns length of the list s.

func (*List) Merge

func (s *List) Merge(l *List) *List

Merge merges a List to end of list s.

func (*List) MergeSlice

func (s *List) MergeSlice(arr []interface{}) *List

MergeSlice merge a array slice to end of list s.

func (*List) MergeStringSlice

func (s *List) MergeStringSlice(arr []string) *List

MergeStringSlice merge a array slice to end of list s.

func (*List) Pop

func (s *List) Pop() (v interface{})

Pop returns last value of list s, and remove it.

func (*List) Range

func (s *List) Range(f func(index int, value interface{}) bool)

Range ranges the value in list s, if function f return false, the range loop will break.

func (*List) RangeFast

func (s *List) RangeFast(f func(index int, value interface{}) bool)

RangeFast ranges the value in list s, if function f return false, the range loop will break.

RangeFast do not create a snapshot for range, so you can not modify list s in range loop, indicate do not call Delete(), Add(), Merge() etc.

func (*List) Remove

func (s *List) Remove(idx int)

Remove removes a value on idx in list s.

func (*List) Set

func (s *List) Set(idx int, v interface{})

Set sets a value on idx in list s.

func (*List) Shift

func (s *List) Shift() (v interface{})

Shift returns first value of list s, and remove it.

func (*List) String

func (s *List) String() string

String returns string format of the list.

func (*List) Sub

func (s *List) Sub(start, end int) *List

Sub returns the sub list between two ranges With x the start and y the end, we are sending [x,y) sublist.

func (*List) ToSlice

func (s *List) ToSlice() []interface{}

ToSlice returns the list as an array.

func (*List) ToStringSlice

func (s *List) ToStringSlice() []string

ToStringSlice returns the list as an array.

Jump to

Keyboard shortcuts

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