首页 > 文档 > expand()扩大数组
2017
07-21

expand()扩大数组

Name

expand()扩大数组

   

Examples

int[] data = {0, 1, 3, 4};

println(data.length); // Prints “4”

data = expand(data);

println(data.length); // Prints “8”

data = expand(data, 512);

println(data.length); // Prints “512”

 

expand()扩大数组 - 第1张  | Processing编程艺术

PImage[] imgs = new PImage[32];

println(imgs.length); // Prints “32”

imgs = (PImage[]) expand(imgs);

println(imgs.length); // Prints “64”

Description

Increases the size of an array. By default, this function doubles the size of the array, but the optional newSize parameter provides precise control over the increase in size. 

When using an array of objects, the data returned from the function must be cast to the object array’s data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray)

增加数组的大小。默认情况下, 此函数使数组的大小加倍, 但可选的 newSize 参数提供对大小增加的精确控制。

 

当使用对象数组时, 从函数返回的数据必须转换为对象数组的数据类型。例如: SomeClass [] = (SomeClass []) 展开 (originalArray)

Syntax

expand(list)

expand(list, newSize)

Parameters

list

Object, String[], double[], float[], long[], int[], char[], byte[], or boolean[]: the array to expand要扩大的数组

newSize

int: new size for the array数组新的大小

Returns

boolean[], byte[], char[], int[], long[], float[], double[], String[], or Object

Related

shorten()



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。