Documentation ¶
Overview ¶
Package hashbidimap implements a bidirectional map backed by two hashmaps.
A bidirectional map, or hash bag, is an associative data structure in which the (key,value) pairs form a one-to-one correspondence. Thus the binary relation is functional in each direction: value can also act as a key to key. A pair (a,b) thus provides a unique coupling between 'a' and 'b' so that 'b' can be found when 'a' is used as a key and 'a' can be found when 'b' is used as a key.
Elements are unordered in the map.
Structure is not thread safe.
Index ¶
- type Map
- func (m *Map) Clear()
- func (m *Map) Empty() bool
- func (m *Map) Get(key interface{}) (value interface{}, found bool)
- func (m *Map) GetKey(value interface{}) (key interface{}, found bool)
- func (m *Map) Keys() []interface{}
- func (m *Map) Put(key interface{}, value interface{})
- func (m *Map) Remove(key interface{})
- func (m *Map) Size() int
- func (m *Map) String() string
- func (m *Map) Values() []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
Map holds the elements in two hashmaps.
func (*Map) Get ¶
Get searches the element in the map by key and returns its value or nil if key is not found in map. Second return parameter is true if key was found, otherwise false.
func (*Map) GetKey ¶
GetKey searches the element in the map by value and returns its key or nil if value is not found in map. Second return parameter is true if value was found, otherwise false.
func (*Map) Put ¶
func (m *Map) Put(key interface{}, value interface{})
Put inserts element into the map.
func (*Map) Remove ¶
func (m *Map) Remove(key interface{})
Remove removes the element from the map by key.