datastructs

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: GPL-3.0 Imports: 3 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToInterfaceSlice

func ToInterfaceSlice(slice interface{}) []interface{}

ToInterfaceSlice converts any slice object to an array of interface{} it can be usefull to initialize some datastructs

Types

type BitSet

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

BitSet structure definition

func NewBitSet

func NewBitSet(size int) (bs *BitSet)

NewBitSet creates a new bitset

func (*BitSet) Get

func (b *BitSet) Get(o int) bool

Get the value of bit at offset o

func (*BitSet) Len

func (b *BitSet) Len() int

Len returns the length of the BitSet

func (*BitSet) Set

func (b *BitSet) Set(o int)

Set bit at offset o

type Container

type Container interface {
	Equal(Container) bool
	Contains(interface{}) bool
	List() []interface{}
	Len() int
}

type HashMap

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

func NewHashMap

func NewHashMap() (hm HashMap)

func (*HashMap) Contains

func (hm *HashMap) Contains(h Hashable) bool

Contains returns true if the HashMap contains element referenced by key

func (*HashMap) Del

func (hm *HashMap) Del(key Hashable)

Del deletes the key and its associated value

func (*HashMap) Get

func (hm *HashMap) Get(h Hashable) (interface{}, bool)

Get the element referenced by key in the HashMap

func (*HashMap) Items

func (hm *HashMap) Items() (ci chan Item)

Items returns a channel of Item contained in the HashMap

func (*HashMap) Keys

func (hm *HashMap) Keys() (ch chan Hashable)

Keys returns a channel of Keys used by the HashMap

func (*HashMap) Len

func (hm *HashMap) Len() int

Len returns the length of the HashMap

func (*HashMap) Set

func (hm *HashMap) Set(key Hashable, value interface{})

Set sets key, value in the map

func (*HashMap) Values

func (hm *HashMap) Values() (ci chan interface{})

Values returns a channel of Values contained in the HashMap

type Hashable

type Hashable interface {
	Hash() string
}

type Item

type Item struct {
	Key   Hashable
	Value interface{}
}

type Sortable

type Sortable interface {
	Less(*Sortable) bool
}

Sortable interface definition

type SortedSlice

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

SortedSlice structure by convention the smallest value is at the end

func NewSortedSlice

func NewSortedSlice(opts ...int) (ss SortedSlice)

NewSortedSlice returns an empty initialized slice. Opts takes len and cap in order to initialize the underlying slice

func (*SortedSlice) Control

func (ss *SortedSlice) Control() bool

Control controls if the slice has been properly ordered. A return value of true means it is in good order

func (*SortedSlice) Insert

func (ss *SortedSlice) Insert(e Sortable)

Insertion method in the slice for a structure implementing Sortable

func (*SortedSlice) Iter

func (ss *SortedSlice) Iter(idx ...int) (c chan Sortable)

Iter returns a chan of Sortable in the slice. Start and Stop indexes can be specified via optional parameters

func (*SortedSlice) RangeLessThan

func (ss *SortedSlice) RangeLessThan(e Sortable) (int, int)

RangeLessThan returns the indexes of the objects Less than Sortable

func (*SortedSlice) ReversedIter

func (ss *SortedSlice) ReversedIter(idx ...int) (c chan Sortable)

Iter returns a chan of Sortable in the slice but in reverse order. Start and Stop indexes can be specified via optional parameters

func (*SortedSlice) Slice

func (ss *SortedSlice) Slice() []Sortable

Slice returns the underlying slice

func (*SortedSlice) String

func (ss *SortedSlice) String() string

String fmt helper

type SyncedHashMap

type SyncedHashMap struct {
	sync.RWMutex
	HashMap
}

SyncedHashMap is a thread safe HashMap

func NewSyncedHashMap

func NewSyncedHashMap() (hm SyncedHashMap)

NewSyncedHashMap SyncedHashMap constructor

func (*SyncedHashMap) Contains

func (hm *SyncedHashMap) Contains(key Hashable) bool

Contains returns true if the HashMap contains element referenced by key

func (*SyncedHashMap) Del

func (hm *SyncedHashMap) Del(key Hashable)

Del deletes the key and its associated value

func (*SyncedHashMap) Get

func (hm *SyncedHashMap) Get(key Hashable) (interface{}, bool)

Get the element referenced by key in the HashMap

func (*SyncedHashMap) Items

func (hm *SyncedHashMap) Items() (ci chan Item)

Items returns a channel of Item contained in the HashMap

func (*SyncedHashMap) Keys

func (hm *SyncedHashMap) Keys() (ch chan Hashable)

Keys returns a channel of Keys used by the HashMap

func (*SyncedHashMap) Len

func (hm *SyncedHashMap) Len() int

Len returns the length of the HashMap

func (*SyncedHashMap) Set

func (hm *SyncedHashMap) Set(key Hashable, value interface{})

Set sets key, value in the map

func (*SyncedHashMap) Values

func (hm *SyncedHashMap) Values() (ci chan interface{})

Values returns a channel of Values contained in the HashMap

type SyncedMap

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

func NewSyncedMap

func NewSyncedMap() (s SyncedMap)

func (*SyncedMap) Add

func (s *SyncedMap) Add(key, value interface{})

func (*SyncedMap) Contains

func (s *SyncedMap) Contains(key interface{}) (ok bool)

func (*SyncedMap) Del

func (s *SyncedMap) Del(key interface{})

func (*SyncedMap) Get

func (s *SyncedMap) Get(key interface{}) (value interface{}, ok bool)

func (*SyncedMap) Keys

func (s *SyncedMap) Keys() chan interface{}

func (*SyncedMap) Len

func (s *SyncedMap) Len() int

func (*SyncedMap) Values

func (s *SyncedMap) Values() chan interface{}

type SyncedSet

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

SyncedSet datastruct that represent a thread safe set

func NewInitSyncedSet

func NewInitSyncedSet(data ...interface{}) (ss SyncedSet)

func NewSyncedSet

func NewSyncedSet(sets ...*SyncedSet) (ss SyncedSet)

NewSyncedSet constructs a new SyncedSet

func (*SyncedSet) Add

func (s *SyncedSet) Add(datas ...interface{})

Add adds data to the set

func (*SyncedSet) Contains

func (s *SyncedSet) Contains(datas ...interface{}) bool

Contains returns true if the syncedset contains all the data

func (*SyncedSet) Del

func (s *SyncedSet) Del(datas ...interface{})

Del deletes data from the set

func (*SyncedSet) Equal

func (s *SyncedSet) Equal(other *SyncedSet) bool

Equal returns true if both sets are equal

func (*SyncedSet) Intersect

func (s *SyncedSet) Intersect(other *SyncedSet) *SyncedSet

Intersect returns a pointer to a new set containing the intersection of current set and other

func (*SyncedSet) Items added in v1.1.1

func (s *SyncedSet) Items() (c chan interface{})

Items returns a channel with all the elements contained in the set

func (*SyncedSet) Len

func (s *SyncedSet) Len() int

Len returns the length of the syncedset

func (*SyncedSet) List

func (s *SyncedSet) List() *[]interface{}

List returns a pointer to a new list containing the data in the set

func (*SyncedSet) Union

func (s *SyncedSet) Union(other *SyncedSet) *SyncedSet

Union returns a pointer to a new set containing the union of current set and other

Jump to

Keyboard shortcuts

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