Collection
Extends:
一个带有集合变更通知的数组
Constructor Summary
Public Constructor | ||
public |
constructor(items: *) |
Method Summary
Public Methods | ||
public |
在当前集合的最后位置添加一个元素 |
|
public |
在指定位置添加一个元素,与Collection#insert方法相同 |
|
public |
clone(): Collection 复制当前集合 |
|
public |
dispose() 销毁当前集合 |
|
public |
导出当前集合为普通的数组 |
|
public |
获取集合中指定位置上的元素 |
|
public |
查找指定元素在集合中第一次出现的位置 |
|
public |
在指定位置添加一个元素 |
|
public |
移除集合最后一个元素并返回 |
|
public |
在当前集合的最后位置添加一个元素,与Collection#add方法相同 |
|
public |
移除集合中所有的给定元素 |
|
public |
从指定位置移除一个元素 |
|
public |
移除集合第一个元素并返回 |
|
public |
在当前集合的最前位置添加一个元素 |
Protected Methods | ||
protected |
添加一系列的元素 |
|
protected |
getValidIndex(index: number): number 获取一个可用的索引值 |
Public Constructors
public constructor(items: *) source
Params:
Name | Type | Attribute | Description |
items | * |
Public Methods
public addAt(index: number, item: *, options: Object): * source
在指定位置添加一个元素,与Collection#insert方法相同
Params:
Name | Type | Attribute | Description |
index | number | 需要添加的位置,关于位置的计算参考Collection#getValidIndex |
|
item | * | 需要添加的元素 |
|
options | Object |
|
相关选项 |
options.silent | boolean |
|
如果该值为 |
Return:
* | 插入的元素 |
public get(index: number): * source
获取集合中指定位置上的元素
Params:
Name | Type | Attribute | Description |
index | number | 指定位置,如果为负数则从元素最后开始往前计算 |
Return:
* | 指定位置的元素,如果指定的位置超出集合范围,则返回 |
public indexOf(item: *, startIndex: number): number source
查找指定元素在集合中第一次出现的位置
Params:
Name | Type | Attribute | Description |
item | * | 指定查找的元素 |
|
startIndex | number |
|
指定开始查找的位置,如果为负数则从最后位置往前计算,如果超出范围则不进行搜索返回 |
public insert(index: number, item: *, options: Object): * source
在指定位置添加一个元素
Params:
Name | Type | Attribute | Description |
index | number | 需要添加的位置,关于位置的计算参考Collection#getValidIndex |
|
item | * | 需要添加的元素 |
|
options | Object |
|
相关选项 |
options.silent | boolean |
|
如果该值为 |
Return:
* | 插入的元素 |
public push(item: *, options: Object): * source
在当前集合的最后位置添加一个元素,与Collection#add方法相同
Return:
* | 插入的元素 |
public removeAt(index: number, options: Object) source
从指定位置移除一个元素
Params:
Name | Type | Attribute | Description |
index | number | 需要移除的元素的位置,关于位置的计算参考Collection#getValidIndex |
|
options | Object |
|
相关选项 |
options.silent | boolean |
|
如果该值为 |
Protected Methods
protected addArray(items: Array, options: Object) source
添加一系列的元素
此方法为私有方法,不要由外部或子类调用
Throw:
提供的 |