treemap

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Implements a map backed by llrb tree. Elements are ordered by key in the map.

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 holds the elements in a llrb tree

func New

func New(isSafe bool) *Map

func (*Map) Clear

func (m *Map) Clear()

Clear removes all elements from the map.

func (*Map) Empty

func (m *Map) Empty() bool

Empty returns true if map does not contain any elements

func (*Map) Get

func (m *Map) Get(key compare.Comparable) (value interface{}, found bool)

Get searches the element in the map by key and returns its value. Second return parameter is true if key was found, otherwise false. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*Map) Keys

func (m *Map) Keys() []compare.Comparable

Keys returns all keys in-order

func (*Map) Max

func (m *Map) Max() (key compare.Comparable, value interface{})

Max returns the maximum key and its value from the tree map. Returns nil, nil if map is empty.

func (*Map) Min

func (m *Map) Min() (key compare.Comparable, value interface{})

Min returns the minimum key and its value from the tree map. Returns nil, nil if map is empty.

func (*Map) Put

func (m *Map) Put(key compare.Comparable, value interface{})

Put inserts key-value pair into the map. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*Map) Remove

func (m *Map) Remove(key compare.Comparable)

Remove the element from the map by key. Key should adhere to the comparator's type assertion, otherwise method panics.

func (*Map) Size

func (m *Map) Size() int

Size returns number of elements in the map.

func (*Map) Values

func (m *Map) Values() []interface{}

Values returns all values in-order based on the key.

Jump to

Keyboard shortcuts

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