treemap

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color added in v0.1.17

type Color int8
const (
	RED   Color = 0
	BLACK Color = 1
)

func (Color) String added in v0.1.17

func (c Color) String() string

type DescendingEntryIterator added in v0.1.17

type DescendingEntryIterator struct {
	EntryIterator
}

func NewKeyDescendingEntryIterator added in v0.1.17

func NewKeyDescendingEntryIterator(m *Map, first *Entry) *DescendingEntryIterator

func (*DescendingEntryIterator) Next added in v0.1.17

func (it *DescendingEntryIterator) Next() *Entry

type DescendingKeyIterator added in v0.1.17

type DescendingKeyIterator struct {
	EntryIterator
}

func NewDescendingKeyIterator added in v0.1.17

func NewDescendingKeyIterator(m *Map, first *Entry) *DescendingKeyIterator

func (*DescendingKeyIterator) Next added in v0.1.17

func (it *DescendingKeyIterator) Next() KeyType

func (*DescendingKeyIterator) Remove added in v0.1.17

func (it *DescendingKeyIterator) Remove()

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

func NewEntry added in v0.1.17

func NewEntry(key KeyType, val interface{}, parent *Entry) *Entry

func (*Entry) Equals

func (e *Entry) Equals(other *Entry) bool

func (*Entry) GetKey

func (e *Entry) GetKey() KeyType

func (*Entry) GetValue

func (e *Entry) GetValue() interface{}

func (*Entry) SetValue

func (e *Entry) SetValue(val interface{}) interface{}

type EntryAction added in v0.1.17

type EntryAction func(key KeyType, val interface{})

type EntryIterator added in v0.1.17

type EntryIterator struct {
	// contains filtered or unexported fields
}

func NewEntryIterator added in v0.1.17

func NewEntryIterator(m *Map, first *Entry) *EntryIterator

func (*EntryIterator) HasNext added in v0.1.17

func (it *EntryIterator) HasNext() bool

func (*EntryIterator) Next added in v0.1.17

func (it *EntryIterator) Next() *Entry

func (*EntryIterator) Remove added in v0.1.17

func (it *EntryIterator) Remove()

Removes from the underlying collection the last element returned

type KeyIterator added in v0.1.17

type KeyIterator struct {
	EntryIterator
}

func NewKeyIterator added in v0.1.17

func NewKeyIterator(m *Map, first *Entry) *KeyIterator

func (*KeyIterator) Next added in v0.1.17

func (it *KeyIterator) Next() KeyType

type KeyType

type KeyType collections.Comparable

type Map

type Map struct {
	// contains filtered or unexported fields
}

A Red-Black tree based map implementation. more details see [java.util.TreeMap](https://bit.ly/3rQWBYO)

func New

func New() *Map

func (*Map) CeilingEntry added in v0.1.17

func (m *Map) CeilingEntry(key KeyType) *Entry

Gets the entry corresponding to the specified key; returns the entry for the least key greater than the specified key if not exist.

func (*Map) CeilingKey added in v0.1.17

func (m *Map) CeilingKey(key KeyType) KeyType

Gets the specified key, return the least key greater than the specified key if not exist.

func (*Map) Clear

func (m *Map) Clear()

Removes all the mappings from this map.

func (*Map) Contains

func (m *Map) Contains(key KeyType) bool

Return true if this map contains a mapping for the specified key

func (*Map) DescendingIterator added in v0.1.17

func (m *Map) DescendingIterator() *DescendingEntryIterator

func (*Map) DescendingKeyIterator added in v0.1.17

func (m *Map) DescendingKeyIterator() *DescendingKeyIterator

func (*Map) FirstEntry added in v0.1.17

func (m *Map) FirstEntry() *Entry

func (*Map) FirstKey

func (m *Map) FirstKey() KeyType

Returns the first key in the TreeMap (according to the key's order)

func (*Map) FloorEntry added in v0.1.17

func (m *Map) FloorEntry(key KeyType) *Entry

Gets the entry corresponding to the specified key; if no such entry exists, returns the entry for the greatest key less than the specified key;

func (*Map) FloorKey added in v0.1.17

func (m *Map) FloorKey(key KeyType) KeyType

Gets the specified key, returns the greatest key less than the specified key if not exist.

func (*Map) Foreach

func (m *Map) Foreach(action EntryAction)

Performs the given action for each entry in this map until all entries have been processed or the action panic

func (*Map) Get

func (m *Map) Get(key KeyType) (interface{}, bool)

Returns the value to which the specified key is mapped, or nil if this map contains no mapping for the key.

func (*Map) GetOrDefault

func (m *Map) GetOrDefault(key KeyType, defaultValue interface{}) interface{}

Returns the value to which the specified key is mapped, or `defaultValue` if this map contains no mapping for the key.

func (*Map) HigherEntry added in v0.1.17

func (m *Map) HigherEntry(key KeyType) *Entry

Gets the entry for the least key greater than the specified key

func (*Map) HigherKey added in v0.1.17

func (m *Map) HigherKey(key KeyType) KeyType

Returns the least key greater than the specified key

func (*Map) InOrderTraversal added in v0.1.17

func (m *Map) InOrderTraversal(action EntryAction)

in-order traversal

func (*Map) IsEmpty

func (m *Map) IsEmpty() bool

func (*Map) Iterator added in v0.1.17

func (m *Map) Iterator() *EntryIterator

func (*Map) KeyIterator added in v0.1.17

func (m *Map) KeyIterator() *KeyIterator

func (*Map) Keys

func (m *Map) Keys() []KeyType

Return list of all keys

func (*Map) LastEntry added in v0.1.17

func (m *Map) LastEntry() *Entry

func (*Map) LastKey

func (m *Map) LastKey() KeyType

Returns the last key in the TreeMap (according to the key's order)

func (*Map) PostOrderTraversal added in v0.1.17

func (m *Map) PostOrderTraversal(action EntryAction)

post-order traversal

func (*Map) PreOrderTraversal added in v0.1.17

func (m *Map) PreOrderTraversal(action EntryAction)

pre-order traversal

func (*Map) Put

func (m *Map) Put(key KeyType, value interface{}) interface{}

Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.

func (*Map) Remove

func (m *Map) Remove(key KeyType) bool

Removes the mapping for this key from this TreeMap if present.

func (*Map) Size

func (m *Map) Size() int

Returns the number of key-value mappings in this map.

func (*Map) ValueIterator added in v0.1.17

func (m *Map) ValueIterator() *ValueIterator

func (*Map) Values

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

Return list of all values

type ValueIterator added in v0.1.17

type ValueIterator struct {
	EntryIterator
}

func NewValueIterator added in v0.1.17

func NewValueIterator(m *Map, first *Entry) *ValueIterator

func (*ValueIterator) Next added in v0.1.17

func (it *ValueIterator) Next() interface{}

Jump to

Keyboard shortcuts

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