datastructs

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: GPL-3.0 Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToInterfaceSlice

func ToInterfaceSlice(slice interface{}) (is []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 Element added in v1.1.5

type Element struct {
	Value interface{}
	Prev  *Element
	Next  *Element
}

func (*Element) String added in v1.1.5

func (e *Element) String() string

type Fifo added in v1.1.5

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

func (*Fifo) Empty added in v1.1.5

func (f *Fifo) Empty() bool

func (*Fifo) Len added in v1.1.5

func (f *Fifo) Len() int

func (*Fifo) Pop added in v1.1.5

func (f *Fifo) Pop() *Element

func (*Fifo) Push added in v1.1.5

func (f *Fifo) Push(i interface{})

func (*Fifo) String added in v1.1.5

func (f *Fifo) String() string

type HashMap

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

func NewHashMap

func NewHashMap() (hm *HashMap)

func (*HashMap) Add added in v1.3.0

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

Add sets key, value in the map

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) 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 RingSet added in v1.2.0

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

func NewRingSet added in v1.2.0

func NewRingSet(len int) *RingSet

func (*RingSet) Add added in v1.2.0

func (r *RingSet) Add(item interface{})

func (*RingSet) Contains added in v1.2.0

func (r *RingSet) Contains(item ...interface{}) bool

func (*RingSet) Copy added in v1.2.0

func (r *RingSet) Copy() *RingSet

func (*RingSet) GetItem added in v1.2.0

func (r *RingSet) GetItem(i int) interface{}

func (*RingSet) Len added in v1.2.0

func (r *RingSet) Len() int

func (*RingSet) MarshalJSON added in v1.2.0

func (r *RingSet) MarshalJSON() ([]byte, error)

func (*RingSet) RingSlice added in v1.2.0

func (r *RingSet) RingSlice() *RingSlice

func (*RingSet) Set added in v1.2.0

func (r *RingSet) Set() *Set

func (*RingSet) SetItem added in v1.2.0

func (r *RingSet) SetItem(i int, item interface{})

func (*RingSet) Slice added in v1.3.0

func (r *RingSet) Slice() []interface{}

func (RingSet) String added in v1.2.0

func (r RingSet) String() string

func (*RingSet) UnmarshalJSON added in v1.2.0

func (r *RingSet) UnmarshalJSON(data []byte) (err error)

type RingSlice added in v1.1.9

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

func NewRingSlice added in v1.1.9

func NewRingSlice(len int) *RingSlice

func (*RingSlice) Add added in v1.1.9

func (r *RingSlice) Add(item interface{})

func (*RingSlice) Copy added in v1.2.0

func (r *RingSlice) Copy() *RingSlice

func (*RingSlice) GetItem added in v1.2.0

func (r *RingSlice) GetItem(i int) interface{}

func (*RingSlice) Len added in v1.1.9

func (r *RingSlice) Len() int

func (*RingSlice) MarshalJSON added in v1.1.9

func (r *RingSlice) MarshalJSON() ([]byte, error)

func (*RingSlice) SetItem added in v1.2.0

func (r *RingSlice) SetItem(i int, item interface{})

func (*RingSlice) Slice added in v1.3.0

func (r *RingSlice) Slice() []interface{}

func (RingSlice) String added in v1.1.9

func (r RingSlice) String() string

func (*RingSlice) UnmarshalJSON added in v1.1.9

func (r *RingSlice) UnmarshalJSON(data []byte) (err error)

type Set added in v1.2.0

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

Set datastruct that represent a thread safe set

func NewInitSet added in v1.2.0

func NewInitSet(data ...interface{}) *Set

NewInitSet constructs a new SyncedSet initialized with data

func NewSet added in v1.2.0

func NewSet(sets ...*Set) *Set

NewSet constructs a new SyncedSet

func (*Set) Add added in v1.2.0

func (s *Set) Add(data ...interface{})

Add adds data to the set

func (*Set) Contains added in v1.2.0

func (s *Set) Contains(data ...interface{}) bool

Contains returns true if the set contains all the data

func (*Set) Copy added in v1.2.0

func (s *Set) Copy() *Set

Copy returns a copy of the current set

func (*Set) Del added in v1.2.0

func (s *Set) Del(data ...interface{})

Del deletes data from the set

func (*Set) Equal added in v1.2.0

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

Equal returns true if both sets are equal

func (*Set) Intersect added in v1.2.0

func (s *Set) Intersect(other *Set) *Set

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

func (*Set) Items added in v1.2.0

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

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

func (*Set) Len added in v1.2.0

func (s *Set) Len() int

Len returns the length of the syncedset

func (*Set) MarshalJSON added in v1.2.0

func (s *Set) MarshalJSON() (data []byte, err error)

MarshalJSON implements json.Marshaler interface

func (*Set) Slice added in v1.3.0

func (s *Set) Slice() []interface{}

Slice returns a pointer to a new slice containing the data in the set

func (*Set) SortSlice added in v1.3.0

func (s *Set) SortSlice() []interface{}

SortSlice returns a new slice containing the data in the set sorted by order of insertion.

func (*Set) Union added in v1.2.0

func (s *Set) Union(other *Set) *Set

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

func (*Set) UnmarshalJSON added in v1.2.0

func (s *Set) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaler 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) *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
	// contains filtered or unexported fields
}

SyncedHashMap is a thread safe HashMap

func NewSyncedHashMap

func NewSyncedHashMap() (hm *SyncedHashMap)

NewSyncedHashMap SyncedHashMap constructor

func (*SyncedHashMap) Add added in v1.3.0

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

Add sets key, value in the map

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) 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() *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() (keys []interface{})

func (*SyncedMap) Len

func (s *SyncedMap) Len() int

func (*SyncedMap) Values

func (s *SyncedMap) Values() (values []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{}) *SyncedSet

NewInitSyncedSet constructs a new SyncedSet initialized with data

func NewSyncedSet

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

NewSyncedSet constructs a new SyncedSet

func (*SyncedSet) Add

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

Add adds data to the set

func (*SyncedSet) Contains

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

Contains returns true if the syncedset contains all the data

func (*SyncedSet) Del

func (s *SyncedSet) Del(data ...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) MarshalJSON added in v1.1.9

func (s *SyncedSet) MarshalJSON() (data []byte, err error)

MarshalJSON implements json.Marshaler interface

func (*SyncedSet) Slice added in v1.3.0

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

Slice returns a pointer to a new slice 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

func (*SyncedSet) UnmarshalJSON added in v1.1.9

func (s *SyncedSet) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaler interface

Jump to

Keyboard shortcuts

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