xmap

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMap

type IMap interface {
	// Put put (key, value) into map
	//  @param key   key
	//  @param value value
	Put(key, value interface{})

	// Get get value element by key
	//  @param key key
	//  @return value value
	//  @return loaded success is true, fail is false
	Get(key interface{}) (value interface{}, loaded bool)

	// Delete delete element by key in map
	//  @param key key
	Delete(key interface{})

	// Size calc size
	//  @return int map size
	Size() int
}

type LinkedMap

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

func NewLinkedMap

func NewLinkedMap() *LinkedMap

func (*LinkedMap) Delete

func (m *LinkedMap) Delete(key interface{})

Delete delete element by key

@receiver m map
@param key key

func (*LinkedMap) Find

func (m *LinkedMap) Find(key interface{}) bool

Find find key in Map

@receiver m map
@param key key
@return bool loaded loaded success is true, fail is false

func (*LinkedMap) Foreach

func (m *LinkedMap) Foreach(f func(key interface{}, value interface{}) bool)

Foreach O(N)

@receiver m
@param f The function that accepts polling returns true to continue polling and false to terminate polling

func (*LinkedMap) Get

func (m *LinkedMap) Get(key interface{}) (value interface{}, loaded bool)

Get get value by key

@receiver m map
@param key    key
@return value value
@return loaded loaded success is true, fail is false

func (*LinkedMap) GetOrPut

func (m *LinkedMap) GetOrPut(key, value interface{}) (actual interface{}, loaded bool)

GetOrPut Try to add an element to the map. If the element already exists, return the existing element directly without adding it

@receiver m map
@param key   key
@param value value
@return actual key already exists return old value, not exists return new value
@return loaded  success is true, fail is false

func (*LinkedMap) Put

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

Put put key,value

@receiver m map
@param key   key
@param value value

func (*LinkedMap) Size

func (m *LinkedMap) Size() int

Size map size

@receiver m map
@return int map size

type Map

type Map interface {
	IMap

	// GetOrPut get value when key exist, not exists return new value, value into map, allow nil
	//  @param key   key
	//  @param value value
	//  @return actual Key already exists return old value, not exists return new value
	//  @return loaded uccess is true, fail is false
	GetOrPut(key, value interface{}) (actual interface{}, loaded bool)

	// Foreach O(N)
	//  @param f The function that accepts polling returns true to continue polling and false to terminate polling
	Foreach(f func(interface{}, interface{}) bool)
}

type SimpleLinkedMap

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

func NewSimpleLinkedMap

func NewSimpleLinkedMap() *SimpleLinkedMap

func (*SimpleLinkedMap) Delete

func (m *SimpleLinkedMap) Delete(key interface{})

Delete delete element by key

@receiver m map
@param key key

func (*SimpleLinkedMap) Find

func (m *SimpleLinkedMap) Find(key interface{}) bool

Find find key in map

@receiver m map
@param key key
@return bool loaded success is true, fail is false

func (*SimpleLinkedMap) Foreach

func (m *SimpleLinkedMap) Foreach(f func(key interface{}, value interface{}) bool)

Foreach O(N)

@receiver m
@param f The function that accepts polling returns true to continue polling and false to terminate polling

func (*SimpleLinkedMap) Get

func (m *SimpleLinkedMap) Get(key interface{}) (value interface{}, loaded bool)

Get get element by key

@receiver m map
@param key    key
@return value value
@return loaded  success is true, fail is false

func (*SimpleLinkedMap) GetOrPut

func (m *SimpleLinkedMap) GetOrPut(key, value interface{}) (actual interface{}, loaded bool)

GetOrPut try to add an element to the map. If the element already exists, return the existing element directly without adding it

@receiver m map
@param key   key
@param value value
@return actual Key already exists return old value, not exists return new value
@return loaded  success is true, fail is false

func (*SimpleLinkedMap) Put

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

Put put key,value

@receiver m map
@param key key
@param value value

func (*SimpleLinkedMap) Size

func (m *SimpleLinkedMap) Size() int

Size

@receiver m map
@return int map size

type SimpleMap

type SimpleMap map[interface{}]interface{}

func NewSimpleMap

func NewSimpleMap() *SimpleMap

func (SimpleMap) Delete

func (m SimpleMap) Delete(key interface{})

Delete delete element by key

@receiver m map
@param key key

func (SimpleMap) Find

func (m SimpleMap) Find(key interface{}) bool

Find find key in Map

@receiver m map
@param key key
@return bool loaded success is true, fail is false

func (SimpleMap) Foreach

func (m SimpleMap) Foreach(f func(interface{}, interface{}) bool)

Foreach O(N)

@receiver m map
@param f The function that accepts polling returns true to continue polling and false to terminate polling

func (SimpleMap) Get

func (m SimpleMap) Get(key interface{}) (value interface{}, loaded bool)

Get get value by key, if exist return true, not exist return false

@receiver m map
@param key    key
@return value value
@return loaded success is true, fail is false

func (SimpleMap) GetOrPut

func (m SimpleMap) GetOrPut(key, value interface{}) (actual interface{}, loaded bool)

GetOrPut Try to add an element to the map. If the element already exists, return the existing element directly without adding it

@receiver m map
@param key   key
@param value value
@return actual Key already exists return old value, not exists return new value
@return loaded success is true, fail is false

func (SimpleMap) Put

func (m SimpleMap) Put(key, value interface{})

Put put key,value into map

@receiver m map
@param key   key
@param value value

func (SimpleMap) Size

func (m SimpleMap) Size() int

Size calc map size

@receiver m map
@return int map size

Jump to

Keyboard shortcuts

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