safe

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 1 Imported by: 20

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Int added in v1.0.7

type Int struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Int ...

func NewInt

func NewInt() *Int

NewInt returns a new safe int

func (*Int) Dec added in v1.3.6

func (i *Int) Dec(step int)

Dec decrements the int by step

func (*Int) Get added in v1.0.7

func (i *Int) Get() int

Get returns the int

func (*Int) Inc added in v1.3.6

func (i *Int) Inc(step int)

Inc increments the int by step

func (*Int) Set added in v1.0.7

func (i *Int) Set(value int)

Set sets the int to the given value

type Int64 added in v1.0.7

type Int64 struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Int64 ...

func NewInt64

func NewInt64() *Int64

NewInt64 returns a new safe int

func (*Int64) Dec added in v1.3.6

func (i *Int64) Dec(step int64)

Dec decrements the int by step

func (*Int64) Get added in v1.0.7

func (i *Int64) Get() int64

Get returns the int

func (*Int64) Inc added in v1.3.6

func (i *Int64) Inc(step int64)

Inc increments the int by step

func (*Int64) Set added in v1.0.7

func (i *Int64) Set(value int64)

Set sets the int to the given value

type List added in v1.0.7

type List struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

List ...

func NewList

func NewList(capacity ...int) *List

NewList returns a new safe list

func (*List) Clear added in v1.0.7

func (l *List) Clear()

Clear removes all elements from the list

func (*List) Contains added in v1.0.7

func (l *List) Contains(value interface{}) bool

Contains returns true if the list contains the given element

func (*List) Filter added in v1.0.7

func (l *List) Filter(f func(interface{}) bool) *List

Filter returns a new list with all elements that satisfy the given function

func (*List) Find added in v1.0.7

func (l *List) Find(f func(interface{}) bool) interface{}

Find returns the first element that satisfies the given function

func (*List) First added in v1.0.7

func (l *List) First() interface{}

First returns the first element of the list

func (*List) ForEach added in v1.0.7

func (l *List) ForEach(f func(interface{}) (stop bool))

ForEach iterates over the list and calls the given function for each element

func (*List) Get added in v1.0.7

func (l *List) Get(index int) interface{}

Get returns the element at the given index

func (*List) IndexOf added in v1.0.7

func (l *List) IndexOf(value interface{}) int

IndexOf returns the index of the given element

func (*List) Iterator added in v1.0.8

func (l *List) Iterator() []interface{}

Iterator returns a channel that will yield successive elements of the list

func (*List) Last added in v1.0.7

func (l *List) Last() interface{}

Last returns the last element of the list

func (*List) Length added in v1.0.7

func (l *List) Length() int

Length is an alias of Size

func (*List) Map added in v1.0.7

func (l *List) Map(f func(interface{}) interface{}) *List

Map returns a new list with the result of calling the given function on each element

func (*List) Pop added in v1.0.7

func (l *List) Pop() interface{}

Pop removes and returns the last element of the list

func (*List) Push added in v1.0.7

func (l *List) Push(value interface{})

Push adds an element to the end of the list

func (*List) Reduce added in v1.0.7

func (l *List) Reduce(f func(interface{}, interface{}) interface{}) interface{}

Reduce returns the result of reducing the list to a single value

func (*List) Reverse added in v1.0.7

func (l *List) Reverse() *List

Reverse reverses the list

func (*List) Shift added in v1.0.7

func (l *List) Shift() interface{}

Shift removes and returns the first element of the list

func (*List) Size added in v1.0.7

func (l *List) Size() int

Size returns the number of elements in the list

func (*List) Slice added in v1.0.7

func (l *List) Slice(start int, end int) *List

Slice returns a new list with a copy of a given number of elements from the given index

func (*List) Splice added in v1.0.7

func (l *List) Splice(index int, count int) *List

Splice removes the given number of elements from the given index

func (*List) Swap added in v1.0.7

func (l *List) Swap(index1 int, index2 int)

Swap swaps the elements at the given indices

func (*List) ToSlice added in v1.0.12

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

ToSlice returns the origin map

func (*List) Unshift added in v1.0.7

func (l *List) Unshift(value interface{})

Unshift adds an element to the beginning of the list

type Map added in v1.0.7

type Map struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Map ...

func NewMap

func NewMap() *Map

NewMap returns a new safe map

func (*Map) Clear added in v1.0.7

func (m *Map) Clear() error

Clear removes all elements from the map

func (*Map) Del added in v1.0.7

func (m *Map) Del(key string) error

Del deletes a key from the map

func (*Map) Get added in v1.0.7

func (m *Map) Get(key string) interface{}

Get returns the value for a key

func (*Map) Has added in v1.0.9

func (m *Map) Has(key string) bool

Has returns true if the map contains the key

func (*Map) Iterator added in v1.0.8

func (m *Map) Iterator() map[string]interface{}

Iterator returns a channel that will yield all the keys and values in the map

func (*Map) Keys added in v1.0.7

func (m *Map) Keys() []string

Keys returns all the keys in the map

func (*Map) Set added in v1.0.7

func (m *Map) Set(key string, value interface{}) error

Set sets a key = value in the map

func (*Map) ToMap added in v1.0.12

func (m *Map) ToMap() map[string]interface{}

ToMap returns the origin map

type Queue added in v1.0.7

type Queue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Queue ...

func NewQueue

func NewQueue() *Queue

NewQueue returns a new safe queue

func (*Queue) Back added in v1.0.7

func (q *Queue) Back() interface{}

Back returns the last element of the queue

func (*Queue) Clear added in v1.0.7

func (q *Queue) Clear()

Clear removes all elements from the queue

func (*Queue) Dequeue added in v1.0.7

func (q *Queue) Dequeue() interface{}

Dequeue removes and returns the first element of the queue

func (*Queue) Enqueue added in v1.0.7

func (q *Queue) Enqueue(value interface{})

Enqueue adds an element to the end of the queue

func (*Queue) Front added in v1.0.7

func (q *Queue) Front() interface{}

Front returns the first element of the queue

func (*Queue) IsEmpty added in v1.0.7

func (q *Queue) IsEmpty() bool

IsEmpty returns true if the queue is empty

func (*Queue) Size added in v1.0.7

func (q *Queue) Size() int

Size returns the number of elements in the queue

type Stack added in v1.0.7

type Stack struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Stack ...

func NewStack

func NewStack() *Stack

NewStack returns a new safe stack

func (*Stack) Clear added in v1.0.7

func (m *Stack) Clear(key string)

Clear removes all elements from the stack

func (*Stack) IsEmpty added in v1.0.7

func (m *Stack) IsEmpty(key string) bool

IsEmpty returns true if the stack is empty

func (*Stack) Peek added in v1.0.7

func (m *Stack) Peek(key string) interface{}

Peek returns the last element of the stack

func (*Stack) Pop added in v1.0.7

func (m *Stack) Pop(key string) interface{}

Pop removes and returns the last element of the stack

func (*Stack) Push added in v1.0.7

func (m *Stack) Push(key string, value interface{})

Push adds an element to the end of the stack

func (*Stack) Size added in v1.0.7

func (m *Stack) Size(key string) int

Size returns the number of elements in the stack

type String added in v1.0.7

type String struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

String ...

func NewString

func NewString() *String

NewString returns a new safe string

func (*String) Get added in v1.0.7

func (i *String) Get() string

Get returns the string

func (*String) Set added in v1.0.7

func (i *String) Set(value string)

Set sets the string to the given value

Jump to

Keyboard shortcuts

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