concurrent

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker func(interface{}, interface{}) bool

Checker is a function type. You can see it as a function that you have to implement for each structure you want to add inside the slice. It should be passed as parameter at the Check() or Get() methods.

type Map

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

Map type that can be safely shared between goroutines that require read/write access to a map

func NewMap

func NewMap() *Map

NewMap ...

func (*Map) Delete

func (cm *Map) Delete(key string) bool

Delete a key from a concurrent map

func (*Map) Get

func (cm *Map) Get(key string) (interface{}, bool)

Get a key from a concurrent map

func (*Map) GetAll

func (cm *Map) GetAll() ([]interface{}, bool)

GetAll returns all the items of the concurrent map

func (*Map) Iter

func (cm *Map) Iter() <-chan MapItem

Iter iterates over the items in a concurrent map. Each item is sent over a channel, so that we can iterate over the map using the builtin range keyword.

func (*Map) Keys

func (cm *Map) Keys() (keys []string)

Keys returns all the keys of the map

func (*Map) Pop

func (cm *Map) Pop(key string) (interface{}, bool)

Pop a key from a concurrent map

func (*Map) Set

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

Set a key in a concurrent map

func (*Map) Size

func (cm *Map) Size() int

Size ...

type MapItem

type MapItem struct {
	Key   string
	Value interface{}
}

MapItem represents a concurrent map item

type Slice

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

Slice type that can be safely shared between goroutines

func (*Slice) Append

func (cs *Slice) Append(item interface{})

Append adds an item to the concurrent slice

func (*Slice) Check

func (cs *Slice) Check(value interface{}, f Checker) bool

Check tests if the passed value exists in the concurrent slice

func (*Slice) Delete

func (cs *Slice) Delete(value interface{}, f Checker) error

Delete removes the specified item from the slice

func (*Slice) Get

func (cs *Slice) Get(value interface{}, f Checker) interface{}

Get will return the interface corresponding with the value and the Checker given. If no Checker is given, then we're comparing interface.

func (*Slice) GetAll

func (cs *Slice) GetAll() ([]interface{}, bool)

GetAll returns all items in the concurrent slice present when the caller calls it

func (*Slice) GetOne

func (cs *Slice) GetOne() (interface{}, bool)

GetOne returns one random item

func (*Slice) Iter

func (cs *Slice) Iter() <-chan SliceItem

Iter iterates over the items in the concurrent slice Each item is sent over a channel, so that we can iterate over the slice using the built-in range keyword

func (*Slice) Pop

func (cs *Slice) Pop() (interface{}, error)

Pop returns the last item in the concurrent slice and remove it for the latter

func (*Slice) PopAll

func (cs *Slice) PopAll() ([]interface{}, error)

PopAll returns all the items of the concurrent slice and empties it

func (*Slice) Size

func (cs *Slice) Size() int

Size returns the length of the concurrent slice

type SliceItem

type SliceItem struct {
	Index int
	Value interface{}
}

SliceItem is a concurrent slice item

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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