本文整理了Java中com.badlogic.gdx.utils.Array.resize()
方法的一些代码示例,展示了Array.resize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.resize()
方法的具体详情如下:
包路径:com.badlogic.gdx.utils.Array
类名称:Array
方法名:resize
[英]Creates a new backing array with the specified size containing the current items.
[中]创建包含当前项的指定大小的新备份数组。
代码示例来源:origin: libgdx/libgdx
/** Reduces the size of the backing array to the size of the actual items. This is useful to release memory when many items
* have been removed, or if it is known that more items will not be added.
* @return {@link #items} */
public T[] shrink () {
if (items.length != size) resize(size);
return items;
}
代码示例来源:origin: libgdx/libgdx
/** Reduces the size of the backing array to the size of the actual items. This is useful to release memory when many items
* have been removed, or if it is known that more items will not be added.
* @return {@link #items} */
public T[] shrink () {
if (items.length != size) resize(size);
return items;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value1, T value2, T value3, T value4) {
T[] items = this.items;
if (size + 3 >= items.length) items = resize(Math.max(8, (int)(size * 1.8f))); // 1.75 isn't enough when size=5.
items[size] = value1;
items[size + 1] = value2;
items[size + 2] = value3;
items[size + 3] = value4;
size += 4;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value1, T value2, T value3) {
T[] items = this.items;
if (size + 2 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
items[size] = value1;
items[size + 1] = value2;
items[size + 2] = value3;
size += 3;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value1, T value2) {
T[] items = this.items;
if (size + 1 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
items[size] = value1;
items[size + 1] = value2;
size += 2;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value1, T value2, T value3) {
T[] items = this.items;
if (size + 2 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
items[size] = value1;
items[size + 1] = value2;
items[size + 2] = value3;
size += 3;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value) {
T[] items = this.items;
if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
items[size++] = value;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value1, T value2) {
T[] items = this.items;
if (size + 1 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
items[size] = value1;
items[size + 1] = value2;
size += 2;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value) {
T[] items = this.items;
if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
items[size++] = value;
}
代码示例来源:origin: libgdx/libgdx
public void add (T value1, T value2, T value3, T value4) {
T[] items = this.items;
if (size + 3 >= items.length) items = resize(Math.max(8, (int)(size * 1.8f))); // 1.75 isn't enough when size=5.
items[size] = value1;
items[size + 1] = value2;
items[size + 2] = value3;
items[size + 3] = value4;
size += 4;
}
代码示例来源:origin: libgdx/libgdx
/** Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many
* items to avoid multiple backing array resizes.
* @return {@link #items} */
public T[] ensureCapacity (int additionalCapacity) {
if (additionalCapacity < 0) throw new IllegalArgumentException("additionalCapacity must be >= 0: " + additionalCapacity);
int sizeNeeded = size + additionalCapacity;
if (sizeNeeded > items.length) resize(Math.max(8, sizeNeeded));
return items;
}
代码示例来源:origin: libgdx/libgdx
public void addAll (T[] array, int start, int count) {
T[] items = this.items;
int sizeNeeded = size + count;
if (sizeNeeded > items.length) items = resize(Math.max(8, (int)(sizeNeeded * 1.75f)));
System.arraycopy(array, start, items, size, count);
size += count;
}
代码示例来源:origin: libgdx/libgdx
public void addAll (T[] array, int start, int count) {
T[] items = this.items;
int sizeNeeded = size + count;
if (sizeNeeded > items.length) items = resize(Math.max(8, (int)(sizeNeeded * 1.75f)));
System.arraycopy(array, start, items, size, count);
size += count;
}
代码示例来源:origin: libgdx/libgdx
/** Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many
* items to avoid multiple backing array resizes.
* @return {@link #items} */
public T[] ensureCapacity (int additionalCapacity) {
if (additionalCapacity < 0) throw new IllegalArgumentException("additionalCapacity must be >= 0: " + additionalCapacity);
int sizeNeeded = size + additionalCapacity;
if (sizeNeeded > items.length) resize(Math.max(8, sizeNeeded));
return items;
}
代码示例来源:origin: libgdx/libgdx
public void insert (int index, T value) {
if (index > size) throw new IndexOutOfBoundsException("index can't be > size: " + index + " > " + size);
T[] items = this.items;
if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
if (ordered)
System.arraycopy(items, index, items, index + 1, size - index);
else
items[size] = items[index];
size++;
items[index] = value;
}
代码示例来源:origin: libgdx/libgdx
public void insert (int index, T value) {
if (index > size) throw new IndexOutOfBoundsException("index can't be > size: " + index + " > " + size);
T[] items = this.items;
if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f)));
if (ordered)
System.arraycopy(items, index, items, index + 1, size - index);
else
items[size] = items[index];
size++;
items[index] = value;
}
代码示例来源:origin: libgdx/libgdx
/** Sets the array size, leaving any values beyond the current size null.
* @return {@link #items} */
public T[] setSize (int newSize) {
truncate(newSize);
if (newSize > items.length) resize(Math.max(8, newSize));
size = newSize;
return items;
}
代码示例来源:origin: libgdx/libgdx
/** Sets the array size, leaving any values beyond the current size null.
* @return {@link #items} */
public T[] setSize (int newSize) {
truncate(newSize);
if (newSize > items.length) resize(Math.max(8, newSize));
size = newSize;
return items;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
public void addAll (T[] array, int start, int count) {
T[] items = this.items;
int sizeNeeded = size + count;
if (sizeNeeded > items.length) items = resize(Math.max(8, (int)(sizeNeeded * 1.75f)));
System.arraycopy(array, start, items, size, count);
size += count;
}
代码示例来源:origin: com.badlogicgames.gdx/gdx
/** Sets the array size, leaving any values beyond the current size null.
* @return {@link #items} */
public T[] setSize (int newSize) {
truncate(newSize);
if (newSize > items.length) resize(Math.max(8, newSize));
size = newSize;
return items;
}
内容来源于网络,如有侵权,请联系作者删除!