Documentation
¶
Index ¶
- type Collection
- type ConcurrentHashSet
- func (set *ConcurrentHashSet[T]) Add(e T) bool
- func (set *ConcurrentHashSet[T]) AddAll(c ...T) bool
- func (set *ConcurrentHashSet[T]) Clear()
- func (set *ConcurrentHashSet[T]) Clone() Set[T]
- func (set *ConcurrentHashSet[T]) Contains(e T) bool
- func (set *ConcurrentHashSet[T]) ContainsAll(c ...T) bool
- func (set *ConcurrentHashSet[T]) Equals(o any) bool
- func (set *ConcurrentHashSet[T]) ForEach(handler func(e T) error) error
- func (set *ConcurrentHashSet[T]) IsEmpty() bool
- func (set *ConcurrentHashSet[T]) Iter() <-chan T
- func (set *ConcurrentHashSet[T]) Remove(e T) bool
- func (set *ConcurrentHashSet[T]) RemoveAll(c ...T) bool
- func (set *ConcurrentHashSet[T]) Size() int
- func (set *ConcurrentHashSet[T]) ToSlice() []T
- type HashMap
- func (m *HashMap[K, V]) Clear()
- func (m *HashMap[K, V]) Clone() Map[K, V]
- func (m *HashMap[K, V]) ContainsKey(k K) bool
- func (m *HashMap[K, V]) Equals(o any) bool
- func (m *HashMap[K, V]) ForEach(handler func(K, V) error) error
- func (m *HashMap[K, V]) Get(k K) (V, bool)
- func (m *HashMap[K, V]) GetDefault(k K, defaultVal V) V
- func (m *HashMap[K, V]) IsEmpty() bool
- func (m *HashMap[K, V]) Keys() []K
- func (m *HashMap[K, V]) Put(k K, v V) V
- func (m *HashMap[K, V]) Remove(k K) V
- func (m *HashMap[K, V]) Replace(k K, v V) (V, bool)
- func (m *HashMap[K, V]) Size() int
- func (m *HashMap[K, V]) Values() []V
- type HashSet
- func (set *HashSet[T]) Add(e T) bool
- func (set *HashSet[T]) AddAll(c ...T) bool
- func (set *HashSet[T]) Clear()
- func (set *HashSet[T]) Clone() Set[T]
- func (set *HashSet[T]) Contains(e T) bool
- func (set *HashSet[T]) ContainsAll(c ...T) bool
- func (set *HashSet[T]) Equals(o any) bool
- func (set *HashSet[T]) ForEach(handler func(e T) error) error
- func (set *HashSet[T]) IsEmpty() bool
- func (set *HashSet[T]) Iter() <-chan T
- func (set *HashSet[T]) Remove(e T) bool
- func (set *HashSet[T]) RemoveAll(c ...T) bool
- func (set *HashSet[T]) Size() int
- func (set *HashSet[T]) ToSlice() []T
- type Map
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type Collection[T any] interface { // Add adds the specified element to this collection. Add(e T) bool // AddAll adds all of the elements in the this collection. AddAll(c ...T) bool // Clear removes all of the elements from this collection. Clear() // Contains returns true if this collection contains the specified element. Contains(e T) bool // ContainsAll returns true if this collection contains all of the elements in the specified collection. ContainsAll(c ...T) bool // Equals compares this collection with the object pass from parameter. Equals(o any) bool // ForEach performs the given handler for each elements in the collection until all elements have been processed or the handler returns an error. ForEach(func(e T) error) error // IsEmpty returns true if this collection contains no elements. IsEmpty() bool // Iter returns a channel of all elements in this collection. Iter() <-chan T // Remove removes the specified element from this collection. Remove(e T) bool // RemoveAll removes all of the elements in the specified collection from this collection. RemoveAll(c ...T) bool // Size returns the number of elements in this collection. Size() int // ToSlice returns a slice containing all of the elements in this collection. ToSlice() []T }
Collection is the root interface for this collections framework hierarchy.
type ConcurrentHashSet ¶ added in v0.1.1
type ConcurrentHashSet[T comparable] struct { // contains filtered or unexported fields }
ConcurrentHashSet is a thread-safe set implementation that uses a Golang builtin map to store its elements.
func NewConcurrentHashSet ¶ added in v0.1.1
func NewConcurrentHashSet[T comparable]() *ConcurrentHashSet[T]
NewConcurrentHashSet creates and returns am empty ConcurrentHashSet with the specified type.
func (*ConcurrentHashSet[T]) Add ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Add(e T) bool
Add adds the specified element to this set.
func (*ConcurrentHashSet[T]) AddAll ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) AddAll(c ...T) bool
AddAll adds all of the specified elements to this set.
func (*ConcurrentHashSet[T]) Clear ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Clear()
Clear removes all of the elements from this set.
func (*ConcurrentHashSet[T]) Clone ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Clone() Set[T]
Clone returns a copy of this set.
func (*ConcurrentHashSet[T]) Contains ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Contains(e T) bool
Contains returns true if this set contains the specified element.
func (*ConcurrentHashSet[T]) ContainsAll ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) ContainsAll(c ...T) bool
ContainsAll returns true if this set contains all of the specified elements.
func (*ConcurrentHashSet[T]) Equals ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Equals(o any) bool
Equals compares set with the object pass from parameter.
func (*ConcurrentHashSet[T]) ForEach ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) ForEach(handler func(e T) error) error
ForEach performs the given handler for each elements in the set until all elements have been processed or the handler returns an error.
func (*ConcurrentHashSet[T]) IsEmpty ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) IsEmpty() bool
IsEmpty returns true if this set contains no elements.
func (*ConcurrentHashSet[T]) Iter ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Iter() <-chan T
Iter returns a channel of all elements in this set.
func (*ConcurrentHashSet[T]) Remove ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Remove(e T) bool
Remove removes the specified element from this set.
func (*ConcurrentHashSet[T]) RemoveAll ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) RemoveAll(c ...T) bool
RemoveAll removes all of the specified elements from this set.
func (*ConcurrentHashSet[T]) Size ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) Size() int
Size returns the number of elements in this set.
func (*ConcurrentHashSet[T]) ToSlice ¶ added in v0.1.1
func (set *ConcurrentHashSet[T]) ToSlice() []T
ToSlice returns a slice containing all of the elements in this set.
type HashMap ¶ added in v0.1.2
type HashMap[K comparable, V any] map[K]V
HashMap is a Golang builtin map wrapper.
func NewHashMap ¶ added in v0.1.2
func NewHashMap[K comparable, V any]() *HashMap[K, V]
NewHashMap creates a new HashMap.
func (*HashMap[K, V]) Clear ¶ added in v0.1.2
func (m *HashMap[K, V]) Clear()
Clear removes all key-value pairs in this map.
func (*HashMap[K, V]) ContainsKey ¶ added in v0.1.2
ContainsKey returns true if this map contains a key-value pair with the specified key.
func (*HashMap[K, V]) Equals ¶ added in v0.1.2
Equals compares this map with the object pass from parameter.
func (*HashMap[K, V]) ForEach ¶ added in v0.1.2
ForEach performs the given handler for each key-value pairs in the map until all pairs have been processed or the handler returns an error.
func (*HashMap[K, V]) Get ¶ added in v0.1.2
Get returns the value which associated to the specified key.
func (*HashMap[K, V]) GetDefault ¶ added in v0.1.2
func (m *HashMap[K, V]) GetDefault(k K, defaultVal V) V
GetDefault returns the value associated with the specified key, and returns the default value if this map contains no pair with the key.
func (*HashMap[K, V]) Keys ¶ added in v0.1.2
func (m *HashMap[K, V]) Keys() []K
Keys returns a slice that contains all the keys in this map.
func (*HashMap[K, V]) Put ¶ added in v0.1.2
func (m *HashMap[K, V]) Put(k K, v V) V
Put associate the specified value with the specified key in this map.
func (*HashMap[K, V]) Remove ¶ added in v0.1.2
func (m *HashMap[K, V]) Remove(k K) V
Remove removes the key-value pair with the specified key.
func (*HashMap[K, V]) Replace ¶ added in v0.1.2
Replace replaces the value for the specified key only if it is currently in this map.
type HashSet ¶
type HashSet[T comparable] map[T]struct{}
HashSet is a set implementation that uses a Golang builtin map to store its elements.
func (*HashSet[T]) Clear ¶
func (set *HashSet[T]) Clear()
Clear removes all of the elements from this set.
func (*HashSet[T]) ContainsAll ¶
ContainsAll returns true if this set contains all of the specified elements.
func (*HashSet[T]) ForEach ¶
ForEach performs the given handler for each elements in the set until all elements have been processed or the handler returns an error.
func (*HashSet[T]) Iter ¶ added in v0.1.1
func (set *HashSet[T]) Iter() <-chan T
Iter returns a channel of all elements in this set.
type Map ¶ added in v0.1.2
type Map[K comparable, V any] interface { // Clear removes all key-value pairs in this map. Clear() // Clone returns a copy of this map. Clone() Map[K, V] // ContainsKey returns true if this map contains a key-value pair with the specified key. ContainsKey(k K) bool // Equals compares this map with the object pass from parameter. Equals(o any) bool // ForEach performs the given handler for each key-value pairs in the map until all pairs have // been processed or the handler returns an error. ForEach(handler func(k K, v V) error) error // Get returns the value which associated to the specified key. Get(k K) (V, bool) // GetDefault returns the value associated with the specified key, and returns the default value // if this map contains no pair with the key. GetDefault(k K, defaultVal V) V // IsEmpty returns true if this map is empty. IsEmpty() bool // Keys returns a slice that contains all the keys in this map. Keys() []K // Put associate the specified value with the specified key in this map. Put(k K, v V) V // Remove removes the key-value pair with the specified key. Remove(k K) V // Replace replaces the value for the specified key only if it is currently in this map. Replace(k K, v V) (V, bool) // Size returns the number of key-value pairs in this map. Size() int // Values returns a slice that contains all the values in this map. Values() []V }
Map is a object that maps keys to values, and it cannot contain duplicate key.
type Set ¶
type Set[T comparable] interface { Collection[T] // Clone returns a copy of this set. Clone() Set[T] }
Set is a collection interface that contains no duplicate elements.