map1

package
v0.0.0-...-f53f79a Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2019 License: MIT, GPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompareFunction

type CompareFunction func(interface{}, interface{}) int8

type ConcurrentMap

type ConcurrentMap interface {
	GenericMap
}

func NewConcurrentMap

func NewConcurrentMap(keyType, elemType reflect.Type) ConcurrentMap

type GenericMap

type GenericMap interface {
	// 获取给定键值对应的元素值。若没有对应元素值则返回nil。
	Get(key interface{}) interface{}
	// 添加键值对,并返回与给定键值对应的旧的元素值。若没有旧元素值则返回(nil, true)。
	Put(key interface{}, elem interface{}) (interface{}, bool)
	// 删除与给定键值对应的键值对,并返回旧的元素值。若没有旧元素值则返回nil。
	Remove(key interface{}) interface{}
	// 清除所有的键值对。
	Clear()
	// 获取键值对的数量。
	Len() int
	// 判断是否包含给定的键值。
	Contains(key interface{}) bool
	// 获取已排序的键值所组成的切片值。
	Keys() []interface{}
	// 获取已排序的元素值所组成的切片值。
	Elems() []interface{}
	// 获取已包含的键值对所组成的字典值。
	ToMap() map[interface{}]interface{}
	// 获取键的类型。
	KeyType() reflect.Type
	// 获取元素的类型。
	ElemType() reflect.Type
}

泛化的Map的接口类型

type Keys

type Keys interface {
	sort.Interface
	Add(k interface{}) bool
	Remove(k interface{}) bool
	Clear()
	Get(index int) interface{}
	GetAll() []interface{}
	Search(k interface{}) (index int, contains bool)
	CompareFunc() CompareFunction
	ElemType() reflect.Type
}

func NewKeys

func NewKeys(
	compareFunc func(interface{}, interface{}) int8,
	elemType reflect.Type) Keys

type OrderedMap

type OrderedMap interface {
	GenericMap // 泛化的Map接口
	// 获取第一个键值。若无任何键值对则返回nil。
	FirstKey() interface{}
	// 获取最后一个键值。若无任何键值对则返回nil。
	LastKey() interface{}
	// 获取由小于键值toKey的键值所对应的键值对组成的OrderedMap类型值。
	HeadMap(toKey interface{}) OrderedMap
	// 获取由小于键值toKey且大于等于键值fromKey的键值所对应的键值对组成的OrderedMap类型值。
	SubMap(fromKey interface{}, toKey interface{}) OrderedMap
	// 获取由大于等于键值fromKey的键值所对应的键值对组成的OrderedMap类型值。
	TailMap(fromKey interface{}) OrderedMap
}

有序的Map的接口类型。

func NewOrderedMap

func NewOrderedMap(keys Keys, elemType reflect.Type) OrderedMap

Jump to

Keyboard shortcuts

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