AttributeMap

一个通过 Attribute 作为键值来界定其元素类型的映射表。

AttributeMap与名称字符串为键的映射表相比,其没有明确的值类型,取而代之的是通过 Attribute 来规定元素类型的。

AttributeMap 不允许存入null值。

example:

class Foo

fun test() {
val fooAttr = attribute<Foo>("foo")

val map = AttributeHashMap()
val foo = Foo()
map[fooAttr] = foo
val foo1 = map[fooAttr]!!
val foo2 = map[attribute<Foo>("foo")]!! // by a new instance

println(foo1 === foo2) // true
}

See also

Types

Link copied to clipboard

Functions

Link copied to clipboard
abstract operator fun <T : Any> contains(attribute: Attribute<T>): Boolean

判断是否存在对应键名与类型的键。

Link copied to clipboard
abstract operator fun <T : Any> get(attribute: Attribute<T>): T?

通过 attribute 得到对应的数据。

Link copied to clipboard
open override fun <T : Any> getAttribute(attribute: Attribute<T>): T?

获取指定值。

Link copied to clipboard
abstract fun size(): Int

数量

Inheritors

Link copied to clipboard
Link copied to clipboard