API
Class

Array ($UI/system/lib/base/array)

使用范围:UI2

Contents

class Array ($UI/system/lib/base/array)

数组工具类

Constructor Top

  Array ()

Static Methods Top

Boolean contains (Array 集合, Any 元素)
void each (Object array, Function action)
Object erase (Array array, Integer index, Integer removeCount)
Object filter (Object array, Function filter)
Object first (Object array, Function predicate, Object predicateOwner)
Any get (Array 集合, Integer 索引)
Any getFirst (Array 集合)
Any getLast (Array 集合)
Integer indexOf (Array array, Object item)
Boolean isEmpty (Array 集合)
Boolean isNotEmpty (Array 集合)
Integer length (Array 集合)
Object mapping (Object array, Function mapping)
Any max (Array 集合)
Array merge (Array array, Object valuesToPush)
Any min (Array 集合)
void remove (Object array, Object itemToRemove)
Array unique (Array array)

Constructor details Top

public Array ()

数组工具类

Static Methods Detail Top

static public Boolean contains (Array 集合, Any 元素)

是否包含对应元素

Parameters

Array 集合
Any 元素

Return Value

Boolean

static public void each (Object array, Function action)

遍历数组执行指定的函数

Parameters

Object array

数组

Function action

函数

Return Value

void

static public Object erase (Array array, Integer index, Integer removeCount)

删除元素

Parameters

Array array

数组

Integer index

序号

Integer removeCount

删除个数

Return Value

Object

数组

static public Object filter (Object array, Function filter)

获取数组中满足指定条件的元素列表

Parameters

Object array

数组

Function filter

匹配函数

Return Value

Object

数组

static public Object first (Object array, Function predicate, Object predicateOwner)

获取满足条件的第一个元素

Parameters

Object array

数组

Function predicate

函数

Object predicateOwner

函数的执行上下文this

Return Value

Object

static public Any get (Array 集合, Integer 索引)

获取指定索引元素

Parameters

Array 集合
Integer 索引

Return Value

Any

static public Any getFirst (Array 集合)

获取首个元素

Parameters

Array 集合

Return Value

Any

static public Any getLast (Array 集合)

获取首个元素

Parameters

Array 集合

Return Value

Any

static public Integer indexOf (Array array, Object item)

获取元素的序号

Parameters

Array array

数组

Object item

元素

Return Value

Integer

static public Boolean isEmpty (Array 集合)

是否为空集合

Parameters

Array 集合

Return Value

Boolean

static public Boolean isNotEmpty (Array 集合)

是否不为空集合

Parameters

Array 集合

Return Value

Boolean

static public Integer length (Array 集合)

获取元素个数

Parameters

Array 集合

Return Value

Integer

static public Object mapping (Object array, Function mapping)

获取数组中每个元素转后的列表

Parameters

Object array

数组

Function mapping

转换函数

Return Value

Object

数组

static public Any max (Array 集合)

获取最大元素

Parameters

Array 集合

Return Value

Any

static public Array merge (Array array, Object valuesToPush)

向数组添加元素

Parameters

Array array

数组

Object valuesToPush

要添加的元素

Return Value

Array

数组

static public Any min (Array 集合)

获取最小元素

Parameters

Array 集合

Return Value

Any

static public void remove (Object array, Object itemToRemove)

删除指定的元素

Parameters

Object array

数组

Object itemToRemove

元素

Return Value

void

static public Array unique (Array array)

获取数组中不重复的元素,如果有重复的,只保留一个

Parameters

Array array

数组

Return Value

Array

数组