utilities

package
v0.0.0-...-958ef34 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

* Copyright (c) 2023 Juice Technologies, Inc. All Rights Reserved.

* Copyright (c) 2023 Juice Technologies, Inc. All Rights Reserved.

* Copyright (c) 2023 Juice Technologies, Inc. All Rights Reserved.

* Copyright (c) 2023 Juice Technologies, Inc. All Rights Reserved.

* Copyright (c) 2023 Juice Technologies, Inc. All Rights Reserved.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCast = errors.New("utilities: invalid cast")
)

Functions

func Cast

func Cast[T any](value any) (T, error)

func Require

func Require[T any](value any) T

func With

func With[V any](variable *ConcurrentVariable[V], callback func(value V))

func WithRef

func WithRef[V any](variable *ConcurrentVariable[V], callback func(value *V))

func WithReturn

func WithReturn[V any, R any](variable *ConcurrentVariable[V], callback func(value V) R) R

Types

type CommaValue

type CommaValue struct {
	Value *[]string
}

A `flag.Value` compatible Value that accepts a comma seperated string and produces an array of strings

func (CommaValue) Set

func (v CommaValue) Set(s string) error

func (CommaValue) String

func (v CommaValue) String() string

type ConcurrentMap

type ConcurrentMap[K comparable, V any] struct {
	sync.Mutex

	Map map[K]V
}

func NewConcurrentMap

func NewConcurrentMap[K comparable, V any]() *ConcurrentMap[K, V]

func (*ConcurrentMap[K, V]) Clear

func (cmap *ConcurrentMap[K, V]) Clear()

func (*ConcurrentMap[K, V]) Delete

func (cmap *ConcurrentMap[K, V]) Delete(key K)

func (*ConcurrentMap[K, V]) Empty

func (cmap *ConcurrentMap[K, V]) Empty() bool

func (*ConcurrentMap[K, V]) Foreach

func (cmap *ConcurrentMap[K, V]) Foreach(callback func(key K, value V) bool)

func (*ConcurrentMap[K, V]) Get

func (cmap *ConcurrentMap[K, V]) Get(key K) (V, bool)

func (*ConcurrentMap[K, V]) Len

func (cmap *ConcurrentMap[K, V]) Len() int

func (*ConcurrentMap[K, V]) Set

func (cmap *ConcurrentMap[K, V]) Set(key K, value V)

type ConcurrentVariable

type ConcurrentVariable[V any] struct {
	sync.Mutex

	Value V
}

func NewConcurrentVariable

func NewConcurrentVariable[V any]() *ConcurrentVariable[V]

func NewConcurrentVariableD

func NewConcurrentVariableD[V any](value V) *ConcurrentVariable[V]

func (*ConcurrentVariable[V]) Get

func (cvar *ConcurrentVariable[V]) Get() V

func (*ConcurrentVariable[V]) Set

func (cvar *ConcurrentVariable[V]) Set(value V)

type LinkedList

type LinkedList[T any] struct {
	// contains filtered or unexported fields
}

func NewLinkedList

func NewLinkedList[T any]() *LinkedList[T]

func (*LinkedList[T]) Append

func (list *LinkedList[T]) Append(data T) *Node[T]

func (*LinkedList[T]) AppendMany

func (list *LinkedList[T]) AppendMany(data []T)

func (*LinkedList[T]) Iterator

func (list *LinkedList[T]) Iterator() NodeIterator[T]

func (*LinkedList[T]) Remove

func (list *LinkedList[T]) Remove(iterator NodeIterator[T]) NodeIterator[T]

func (*LinkedList[T]) RemoveNode

func (list *LinkedList[T]) RemoveNode(current *Node[T]) *Node[T]

type Node

type Node[T any] struct {
	Data T

	N, P *Node[T]
}

type NodeIterator

type NodeIterator[T any] struct {
	// contains filtered or unexported fields
}

func (*NodeIterator[T]) Next

func (iterator *NodeIterator[T]) Next() bool

func (*NodeIterator[T]) Node

func (iterator *NodeIterator[T]) Node() *Node[T]

func (*NodeIterator[T]) Value

func (iterator *NodeIterator[T]) Value() *T

Jump to

Keyboard shortcuts

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