hashmultimaps

package
v0.0.0-...-5ce2504 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 0 Imported by: 1

README

Description

Implement a Multi Map. A collection that maps keys to values, similar to Map, but in which each key may be associated with multiple values.

Example:

Input: Push ("key1", "1"), Push ("key1", "2"), Push ("key2", "3"), Get "key1" 
Output: ["1", "2"]

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HashMultiMap

type HashMultiMap[K, V comparable] struct {
	// contains filtered or unexported fields
}

HashMultiMap a data structure representing a map of keys with lists of values

func New

func New[K, V comparable]() *HashMultiMap[K, V]

New factory that creates a new Hash Multi Map

func (*HashMultiMap[K, V]) Clear

func (s *HashMultiMap[K, V]) Clear()

Clear clears the multiMap

func (*HashMultiMap[K, V]) Contains

func (s *HashMultiMap[K, V]) Contains(key K) bool

Contains checks if a key is in the multi map

func (*HashMultiMap[K, V]) ContainsAll

func (s *HashMultiMap[K, V]) ContainsAll(keys ...K) bool

ContainsAll checks if all keys are in the multi map

func (*HashMultiMap[K, V]) ContainsAny

func (s *HashMultiMap[K, V]) ContainsAny(keys ...K) bool

ContainsAny checks if any keys are in the multi map

func (*HashMultiMap[K, V]) GetKeys

func (s *HashMultiMap[K, V]) GetKeys() []K

GetKeys returns a list of the multi map's keys

func (*HashMultiMap[K, V]) GetValues

func (s *HashMultiMap[K, V]) GetValues(key K) []V

GetValues returns values associated with the key

func (*HashMultiMap[K, V]) IsEmpty

func (s *HashMultiMap[K, V]) IsEmpty() bool

IsEmpty checks if the multiMap is empty

func (*HashMultiMap[K, V]) Merge

func (s *HashMultiMap[K, V]) Merge(maps ...*HashMultiMap[K, V])

Merge merge multiple multi maps

func (*HashMultiMap[K, V]) Put

func (s *HashMultiMap[K, V]) Put(key K, value V)

Put key/value pair to the multi map

func (*HashMultiMap[K, V]) PutAll

func (s *HashMultiMap[K, V]) PutAll(key K, values ...V)

PutAll put key/values to the multi map

func (*HashMultiMap[K, V]) Remove

func (s *HashMultiMap[K, V]) Remove(key K, value V)

Remove removes a value from a key's values

func (*HashMultiMap[K, V]) RemoveKey

func (s *HashMultiMap[K, V]) RemoveKey(keys ...K)

RemoveKey removes a key and all its values

func (*HashMultiMap[K, V]) Size

func (s *HashMultiMap[K, V]) Size() int

Size returns size of the multiMap

Jump to

Keyboard shortcuts

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