cntr

package module
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 4 Imported by: 10

README

cntr

Golang container

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSlice2dEqual added in v1.1.0

func IsSlice2dEqual[T Element](a, b [][]T) bool

比較兩個二維 Slice 是否相同

func IsSliceEqual added in v1.1.0

func IsSliceEqual[T Element](a, b []T) bool

比較兩個 Slice 是否相同

func ModifyIndex added in v1.2.4

func ModifyIndex(index int, length int) int

func Slice2dToString

func Slice2dToString[T Element](slice2d [][]T) string

二維 Slice 轉字串

func SliceToString

func SliceToString[T Element](slice []T) string

Slice 轉字串

Types

type Array

type Array[T Element] struct {
	Elements []T
}

func NewArray

func NewArray[T Element](elements ...T) *Array[T]

func (*Array[T]) Add added in v1.2.4

func (a *Array[T]) Add(v any)

func (*Array[T]) Append

func (a *Array[T]) Append(v interface{})

func (*Array[T]) Clear

func (a *Array[T]) Clear()

func (*Array[T]) Clone

func (a *Array[T]) Clone() *Array[T]

func (*Array[T]) Contains

func (a *Array[T]) Contains(v interface{}) bool

func (*Array[T]) Find

func (a *Array[T]) Find(v interface{}) int

func (*Array[T]) Get added in v1.2.4

func (a *Array[T]) Get(index int) (any, bool)

func (*Array[T]) GetIterator

func (a *Array[T]) GetIterator() *Iterator[T]

func (*Array[T]) GetRange added in v1.2.4

func (a *Array[T]) GetRange(startIndex int, endIndex int) []T

func (*Array[T]) IsEquals

func (a *Array[T]) IsEquals(other *Array[T], isStrict bool) bool

func (*Array[T]) Iter

func (a *Array[T]) Iter() func() (T, bool)

func (*Array[T]) Length

func (a *Array[T]) Length() int

func (*Array[T]) Remove

func (a *Array[T]) Remove(v interface{}) interface{}

func (*Array[T]) Set added in v1.2.4

func (a *Array[T]) Set(index int, value T)

func (*Array[T]) SetRange added in v1.2.4

func (a *Array[T]) SetRange(startIndex int, endIndex int, values []T)

type BikeyMap added in v1.1.1

type BikeyMap[K1 Element, K2 Element, V any] struct {
	// contains filtered or unexported fields
}

func NewBikeyMap added in v1.1.1

func NewBikeyMap[K1 Element, K2 Element, V any]() *BikeyMap[K1, K2, V]

func (*BikeyMap[K1, K2, V]) Add added in v1.1.1

func (m *BikeyMap[K1, K2, V]) Add(key1 K1, key2 K2, value V) error

func (*BikeyMap[K1, K2, V]) ContainKey1 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) ContainKey1(key1 K1) bool

func (*BikeyMap[K1, K2, V]) ContainKey2 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) ContainKey2(key2 K2) bool

func (*BikeyMap[K1, K2, V]) ContainKeys added in v1.1.1

func (m *BikeyMap[K1, K2, V]) ContainKeys(key1 K1, key2 K2) bool

func (*BikeyMap[K1, K2, V]) DelByKey1 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) DelByKey1(key1 K1)

func (*BikeyMap[K1, K2, V]) DelByKey2 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) DelByKey2(key2 K2)

func (*BikeyMap[K1, K2, V]) GetByKey1 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) GetByKey1(key1 K1) (V, bool)

func (*BikeyMap[K1, K2, V]) GetByKey2 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) GetByKey2(key2 K2) (V, bool)

func (*BikeyMap[K1, K2, V]) GetByKeys added in v1.1.1

func (m *BikeyMap[K1, K2, V]) GetByKeys(key1 K1, key2 K2) (V, bool)

根據兩個對應的 Key 來取值,也可確定兩個 Key 是一組的。

func (*BikeyMap[K1, K2, V]) GetIterator added in v1.1.1

func (m *BikeyMap[K1, K2, V]) GetIterator() *Iterator[*Bivalue[K1, K2, V]]

func (*BikeyMap[K1, K2, V]) Set added in v1.1.1

func (m *BikeyMap[K1, K2, V]) Set(key1 K1, key2 K2, value V)

func (*BikeyMap[K1, K2, V]) UpdateByKey1 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) UpdateByKey1(key1 K1, value *Bivalue[K1, K2, V])

func (*BikeyMap[K1, K2, V]) UpdateByKey2 added in v1.1.1

func (m *BikeyMap[K1, K2, V]) UpdateByKey2(key2 K2, value *Bivalue[K1, K2, V])

type Bivalue added in v1.1.1

type Bivalue[K1 Element, K2 Element, V any] struct {
	// contains filtered or unexported fields
}

func NewBivalue added in v1.1.1

func NewBivalue[K1 Element, K2 Element, V any](key1 K1, key2 K2, value V) *Bivalue[K1, K2, V]

func (*Bivalue[K1, K2, V]) GetKey1 added in v1.1.1

func (b *Bivalue[K1, K2, V]) GetKey1() K1

func (*Bivalue[K1, K2, V]) GetKey2 added in v1.1.1

func (b *Bivalue[K1, K2, V]) GetKey2() K2

func (*Bivalue[K1, K2, V]) GetValue added in v1.1.1

func (b *Bivalue[K1, K2, V]) GetValue() V

type Element

type Element interface {
	Int | UInt | Float | string
}

type Float

type Float interface {
	float32 | float64
}

type Int

type Int interface {
	int | int8 | int16 | int32 | int64
}

type Iterator

type Iterator[V any] struct {
	// contains filtered or unexported fields
}

func NewIterator

func NewIterator[V any](datas []V) *Iterator[V]

func (*Iterator[V]) HasNext

func (it *Iterator[V]) HasNext() bool

func (*Iterator[V]) Next

func (it *Iterator[V]) Next() V

type NestedMap added in v1.1.1

type NestedMap[K1 Element, K2 Element, V Element] struct {
	// contains filtered or unexported fields
}

func NewNestedMap added in v1.1.1

func NewNestedMap[K1 Element, K2 Element, V Element]() *NestedMap[K1, K2, V]

func (*NestedMap[K1, K2, V]) Add added in v1.1.1

func (nm *NestedMap[K1, K2, V]) Add(k1 K1, k2 K2, vs []V)

func (*NestedMap[K1, K2, V]) Get added in v1.1.1

func (nm *NestedMap[K1, K2, V]) Get(k1 K1, k2 K2) ([]V, error)

func (*NestedMap[K1, K2, V]) GetByKey1 added in v1.1.1

func (nm *NestedMap[K1, K2, V]) GetByKey1(k1 K1) ([]V, error)

func (*NestedMap[K1, K2, V]) GetByKey2 added in v1.1.1

func (nm *NestedMap[K1, K2, V]) GetByKey2(k2 K2) ([]V, error)

type Set

type Set[T Element] struct {
	Elements map[T]void
	// contains filtered or unexported fields
}

func NewSet

func NewSet[T Element](elements ...T) *Set[T]

func (*Set[T]) Add

func (s *Set[T]) Add(element T) bool

加入數據,返回是否加入成功

func (*Set[T]) Clear

func (s *Set[T]) Clear()

func (*Set[T]) Clone

func (s *Set[T]) Clone() *Set[T]

func (*Set[T]) Contains

func (s *Set[T]) Contains(element T) bool

數據是否存在

func (*Set[T]) GetIterator

func (s *Set[T]) GetIterator() *Iterator[T]

func (*Set[T]) Length

func (s *Set[T]) Length() int

func (*Set[T]) Remove

func (s *Set[T]) Remove(element T) bool

刪除元素,返回是否刪除成功

func (*Set[T]) String added in v1.2.4

func (s *Set[T]) String() string

func (*Set[T]) ToSlice added in v1.2.4

func (s *Set[T]) ToSlice() []T

type UInt

type UInt interface {
	uint | uint8 | uint16 | uint32 | uint64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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