基础功能数据结构Array本页总览Array 描述: 支持各种操作的数组数据结构类。 这个数组类被设计成以1为基数做索引,也就是说数组中的第一项的索引为1。这与Lua语言中用作数组的Lua表的行为一致。 类对象:Array Class。 继承自:Object。 count 类型: 只读成员变量。 描述: 数组中的对象总数。 签名: const count: integer empty 类型: 只读成员变量。 描述: 数组是否为空。 签名: const empty: boolean addRange 类型: 函数。 描述: 将另一个数组中的所有对象添加到该数组的末尾。 签名: addRange: function(self: Array, other: Array) 参数: 参数名类型描述otherArray另一个数组对象。 removeFrom 类型: 函数。 描述: 从该数组中删除所有在另一个数组中也存在的对象。 签名: removeFrom: function(self: Array, other: Array) 参数: 参数名类型描述otherArray另一个数组对象。 clear 类型: 函数。 描述: 从数组中删除所有对象。 签名: clear: function(self: Array) reverse 类型: 函数。 描述: 反转数组中对象的顺序。 签名: reverse: function(self: Array) shrink 类型: 函数。 描述: 从数组末尾删除所有空内存槽位。 用于释放数组持有的但未使用的内存。 签名: shrink: function(self: Array) swap 类型: 函数。 描述: 交换两个给定索引处的对象。 签名: swap: function(self: Array, indexA: integer, indexB: integer) 参数: 参数名类型描述indexAinteger第一个索引。indexBinteger第二个索引。 removeAt 类型: 函数。 描述: 删除给定索引处的对象。 签名: removeAt: function(self: Array, index: integer): boolean 参数: 参数名类型描述indexinteger要删除的索引。 返回值: 返回类型描述boolean如果成功删除对象,则返回true,否则返回false。 fastRemoveAt 类型: 函数。 描述: 快速删除给定索引处的对象。 在无需确保数组中元素的顺序时使用。 签名: fastRemoveAt: function(self: Array, index: integer): boolean 参数: 参数名类型描述indexinteger要删除的索引。 返回值: 返回类型描述boolean如果已删除一项则返回true,否则返回false。 each 类型: 函数。 描述: 对数组中的每个对象调用处理函数。 签名: each: function(self: Array, func: function(Object): boolean): boolean 参数: 参数名类型描述funcfunction要为每个对象调用的函数。如果返回false则继续迭代,返回true则停止。 返回值: 返回类型描述boolean如果迭代完成则返回false,如果处理函数中断了迭代则返回true。 first 类型: 只读成员变量。 描述: 获取数组中的第一项。 签名: const first: Item last 类型: 只读成员变量。 描述: 获取数组中的最后一项。 签名: const last: Item randomObject 类型: 只读成员变量。 描述: 获取数组中的一个随机对象。 签名: const randomObject: Item set 类型: 函数。 描述: 设置给定索引处的对象。 签名: set: function(self: Array, index: integer, item: Item) 参数: 参数名类型描述indexinteger要设置的索引,应从基数1开始。itemItem新的对象值。 get 类型: 函数。 描述: 获取给定索引处的对象。 签名: get: function(self: Array, index: integer): Item 参数: 参数名类型描述indexinteger要获取的索引,应为基数1开始。 返回值: 返回类型描述Item索引处的对象值. add 类型: 函数。 描述: 在数组末尾添加对象。 签名: add: function(self: Array, item: Item) 参数: 参数名类型描述itemItem要添加的对象。 insert 类型: 函数。 描述: 在给定索引处插入对象,并向后移动其它对象。 签名: insert: function(self: Array, index: integer, item: Item) 参数: 参数名类型描述indexinteger要插入的索引。itemItem要插入的对象。 contains 类型: 函数。 描述: 检查数组是否包含给定的对象。 签名: contains: function(self: Array, item: Item): boolean 参数: 参数名类型描述itemItem要检查的对象。 返回值: 返回类型描述boolean如果找到对象则返回True,否则返回false。 index 类型: 函数。 描述: 获取给定对象的索引。 签名: index: function(self: Array, item: Item): integer 参数: 参数名类型描述itemItem要搜索的对象。 返回值: 返回类型描述integer对象的索引,如果未找到则返回0。 removeLast 类型: 函数。 描述: 删除并返回数组中的最后一项。 签名: removeLast: function(self: Array): Item 返回值: 返回类型描述Item数组中的最后一项。 fastRemove 类型: 函数。 描述: 从数组快速删除第一次出现的特定对象。 在无需确保数组中元素的顺序时使用。 签名: fastRemove: function(self: Array, item: Item): boolean 参数: 参数名类型描述itemItem要删除的对象。 返回值: 返回类型