type_utils

package
v1.0.42 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Equal       int = 0
	LessThan    int = -1
	GreaterThan int = 1
)

Variables

This section is empty.

Functions

func BaseTypeToString added in v1.0.35

func BaseTypeToString(raw any) string

func CompareItemsKeys added in v1.0.32

func CompareItemsKeys(a, b any) int

func CompareKeysInsensitive added in v1.0.33

func CompareKeysInsensitive(a, b any) int

func CompareString added in v1.0.25

func CompareString(a, b string) int

func FindElement added in v1.0.30

func FindElement[T any](arr []T, predicate func(T) bool) *T

func GetFiltered added in v1.0.30

func GetFiltered[T any](arr []T, predicate func(T) bool) []T

func InArray added in v1.0.30

func InArray[T comparable](val T, arr []T) bool

Types

type Collection

type Collection[T CollectionItem] struct {
	// contains filtered or unexported fields
}

func NewCollection

func NewCollection[T CollectionItem](items ...T) *Collection[T]

func (*Collection[T]) Add

func (c *Collection[T]) Add(item T)

func (*Collection[T]) Contains

func (c *Collection[T]) Contains(i T) bool

func (*Collection[T]) ContainsKey

func (c *Collection[T]) ContainsKey(n string) bool

func (*Collection[T]) Get

func (c *Collection[T]) Get(key string) (noVal T)

func (*Collection[T]) Len added in v1.0.28

func (c *Collection[T]) Len() int

func (*Collection[T]) Less added in v1.0.28

func (c *Collection[T]) Less(i, j int) bool

func (*Collection[T]) Map added in v1.0.24

func (c *Collection[T]) Map() map[string]T

func (*Collection[T]) Remove

func (c *Collection[T]) Remove(key string)

func (*Collection[T]) Slice added in v1.0.24

func (c *Collection[T]) Slice() []T

func (*Collection[T]) Sort

func (c *Collection[T]) Sort() ICollection[T]

func (*Collection[T]) Swap added in v1.0.28

func (c *Collection[T]) Swap(i, j int)

type CollectionItem

type CollectionItem interface {
	ItemWithKey
	ComparableItem
}

type ComparableItem added in v1.0.26

type ComparableItem interface {
	Compare(other any) int
}

type ICollection added in v1.0.28

type ICollection[T CollectionItem] interface {
	sort.Interface
	Add(item T)
	Get(k string) T
	Remove(k string)
	Contains(i T) bool
	ContainsKey(k string) bool
	Sort() ICollection[T]
	Slice() []T
	Map() map[string]T
}

type ItemWithKey added in v1.0.26

type ItemWithKey interface {
	KeyEqual(other any) bool
	Key() string
}

type ItemWithName added in v1.0.26

type ItemWithName interface {
	Name() string
}

Jump to

Keyboard shortcuts

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