util

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var B32 = b32{}
View Source
var B64 = b64{}

Functions

func Compact

func Compact(data Interface) int

func NewLoggerFrom

func NewLoggerFrom(l *log.Logger) *log.Logger

Types

type Interface

type Interface interface {
	Len() int
	// Called only once for each index. If true, element at index is moved to the right side of the slice.
	Remove(i int) bool
	Swap(i, j int)
}

type Logger

type Logger interface {
	Printf(f string, args ...interface{})
	WithPrefix(prefix string) Logger
}

type NopLogger

type NopLogger struct {
}

func (NopLogger) Printf

func (NopLogger) Printf(f string, args ...interface{})

func (NopLogger) WithPrefix

func (NopLogger) WithPrefix(prefix string) Logger

type StdLogger

type StdLogger struct {
	*log.Logger
}

func (*StdLogger) Printf

func (sl *StdLogger) Printf(f string, args ...interface{})

func (*StdLogger) WithPrefix

func (sl *StdLogger) WithPrefix(prefix string) Logger

type ThreadSafeLinkedList

type ThreadSafeLinkedList struct {
	// contains filtered or unexported fields
}

A light-weight single linked list. Elements are added at the front, multiple additions and iterations can run concurrently and are lockfree. Removal operations are thread-safe and use a lock but run concurrently to additions and iterations. All operations must traverse the list from the front.

func (*ThreadSafeLinkedList) GetAll

func (l *ThreadSafeLinkedList) GetAll() []interface{}

func (*ThreadSafeLinkedList) Iterate

func (l *ThreadSafeLinkedList) Iterate() func() interface{}

func (*ThreadSafeLinkedList) Len

func (l *ThreadSafeLinkedList) Len() int

func (*ThreadSafeLinkedList) Peek

func (l *ThreadSafeLinkedList) Peek() interface{}

Peek returns the element at the front of the list. This is the most recently added element.

func (*ThreadSafeLinkedList) Pop

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

Pop returns and removes the element at the front of the list. This is the most recently added element.

func (*ThreadSafeLinkedList) Push

func (l *ThreadSafeLinkedList) Push(vs ...interface{})

Push inserts given values to the front of the list. Values are inserted in fifo order, i.e. the last value is at the front of the list, the same as if the values would be added in a loop. The values are ensured to be inserted as one sequence, uninterrupted by other concurrrent changes.

func (*ThreadSafeLinkedList) RemoveFirst

func (l *ThreadSafeLinkedList) RemoveFirst(pred func(interface{}) bool) bool

func (*ThreadSafeLinkedList) Snip

func (l *ThreadSafeLinkedList) Snip(when func(interface{}) bool) int

Snip removes all elements from the list after and including the element for which the provided function returns true. The function might be called multiple times for an element.

Jump to

Keyboard shortcuts

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