map2

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README

Documentation

Index

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 is a key-ordered map. The zero value is an invalid map! Use one of the construction functions (e.g., New()), to create a map for a specific key type.

func New

func New(less func(interface{}, interface{}) bool) *Map

New returns an empty Map that uses the given less than function to compare keys. For example:

type Point { X, Y int }
pointMap := omap.New(func(a, b interface{}) bool {
        α, β := a.(Point), b.(Point)
        if α.X != β.X {
            return α.X < β.X
        }
        return α.Y < β.Y
    })

func NewCaseFoldedKeyed

func NewCaseFoldedKeyed() *Map

NewCaseFoldedKeyed returns an empty Map that accepts case-insensitive string keys.

func NewFloat64Keyed

func NewFloat64Keyed() *Map

NewFloat64Keyed returns an empty Map that accepts float64 keys.

func NewIntKeyed

func NewIntKeyed() *Map

NewIntKeyed returns an empty Map that accepts int keys.

func NewStringKeyed

func NewStringKeyed() *Map

NewStringKeyed returns an empty Map that accepts case-sensitive string keys.

func (*Map) Delete

func (m *Map) Delete(key interface{}) (deleted bool)

Delete deletes the key-value with the given key from the Map and returns true, or does nothing and returns false if there is no key-value with the given key. For example:

deleted := myMap.Delete(key).

func (*Map) Do

func (m *Map) Do(function func(interface{}, interface{}))

Do calls the given function on every key-value in the Map in order.

func (*Map) Find

func (m *Map) Find(key interface{}) (value interface{}, found bool)

Find returns the value and true if the key is in the Map or nil and false otherwise. For example:

value, found := myMap.Find(key).

func (*Map) Insert

func (m *Map) Insert(key, value interface{}) (inserted bool)

Insert inserts a new key-value into the Map and returns true; or replaces an existing key-value pair's value if the keys are equal and returns false. For example:

inserted := myMap.Insert(key, value).

func (*Map) Len

func (m *Map) Len() int

Len returns the number of key-value pairs in the map.

Jump to

Keyboard shortcuts

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