MarsArray

new mars2d.MarsArray()

自定义集合存储管理类

属性值

只读 length : Number

获取总数量

只读 values : Array

获取集合中的数组列表

方法

contains(key) → Boolean

确定提供的键是否在数组中

参数名称 类型 描述信息
key String | Number

主键

返回值:

是否在数组中

destroy() → void

销毁对象

返回值:

forEach(method, context) → void

遍历每一个对象并将其作为参数传递给回调函数

参数名称 类型 描述信息
method function

回调方法

context Object 可选

侦听器的上下文(this关键字将指向的对象)。

返回值:

get(key) → *

检索与提供的键关联的值

参数名称 类型 描述信息
key String | Number

主键

返回值:

关联的值,如果键在集合中不存在,则为未定义。

getByAttr(attrValue, attrName, exObj) → *

根据指定属性获取对象

参数名称 类型 默认值 描述信息
attrValue String | Number

属性值

attrName String 'id' 可选

属性键

exObj String 'options' 可选

查找的二级对象属性键

返回值:

关联的值,如果键在集合中不存在,则为未定义。

getListByAttr(attrValue, attrName, exObj) → Array

根据指定属性获取符合条件对象数组

参数名称 类型 默认值 描述信息
attrValue String | Number

属性值

attrName String 'id' 可选

属性键

exObj String 'options' 可选

查找的二级对象属性键

返回值:

数组

remove(key) → Boolean

从集合中移除键值对

参数名称 类型 描述信息
key String | Number

主键

返回值:

是否移除

removeAll() → void

清空集合

返回值:

set(key, value) → void

将提供的键与提供的值关联起来。如果密钥已经存在, 存在时,它将被新值覆盖。

参数名称 类型 描述信息
key String | Number

主键

value *

与提供的键相关联的值

返回值: