public class ShortVLA
extends java.lang.Object
implements java.io.Serializable
ArrayList<Short>
.
If unordered, this class avoids a memory copy when removing elements (the last element is moved to the removed
element's position). Used internally by CoordPacker, and unlikely to be used outside of it.
Constructor and Description |
---|
ShortVLA()
Creates an ordered array with a capacity of 16.
|
ShortVLA(boolean ordered,
int capacity) |
ShortVLA(boolean ordered,
short[] array,
int startIndex,
int count)
Creates a new array containing the elements in the specified array.
|
ShortVLA(int capacity)
Creates an ordered array with the specified capacity.
|
ShortVLA(int[] array)
Creates a new ordered array containing the elements in the specified array, converted to short.
|
ShortVLA(short[] array)
Creates a new ordered array containing the elements in the specified array.
|
ShortVLA(ShortVLA array)
Creates a new array containing the elements in the specific array.
|
Modifier and Type | Method and Description |
---|---|
void |
add(short value) |
void |
addAll(int[] array) |
void |
addAll(short... array) |
void |
addAll(short[] array,
int offset,
int length) |
void |
addAll(ShortVLA array) |
void |
addAll(ShortVLA array,
int offset,
int length) |
void |
addFractionRange(int start,
int end,
int fraction) |
void |
addRange(int start,
int end) |
int[] |
asInts() |
void |
clear() |
boolean |
contains(short value) |
short[] |
ensureCapacity(int additionalCapacity)
Increases the size of the backing array to accommodate the specified number of additional items.
|
boolean |
equals(java.lang.Object object) |
short |
first()
Returns the first item.
|
short |
get(int index) |
int |
hashCode() |
void |
incr(int index,
short value)
Adds value to the item in the ShortVLA at index.
|
int |
indexOf(short value) |
void |
insert(int index,
short value) |
int |
lastIndexOf(short value) |
void |
mul(int index,
short value) |
short |
peek()
Returns the last item.
|
short |
pop()
Removes and returns the last item.
|
boolean |
removeAll(ShortVLA array)
Removes from this array all of elements contained in the specified array.
|
short |
removeIndex(int index)
Removes and returns the item at the specified index.
|
void |
removeRange(int start,
int end)
Removes the items between the specified indices, inclusive.
|
boolean |
removeValue(short value) |
protected short[] |
resize(int newSize) |
void |
reverse() |
void |
set(int index,
short value) |
short[] |
shrink()
Reduces the size of the backing array to the size of the actual items.
|
void |
sort() |
void |
swap(int first,
int second) |
short[] |
toArray() |
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String separator) |
void |
truncate(int newSize)
Reduces the size of the array to the specified size.
|
static ShortVLA |
with(short... array) |
public ShortVLA()
public ShortVLA(int capacity)
public ShortVLA(boolean ordered, int capacity)
ordered
- If false, methods that remove elements may change the order of other elements in the array, which avoids a
memory copy.capacity
- Any elements added beyond this will cause the backing array to be grown.public ShortVLA(ShortVLA array)
public ShortVLA(short[] array)
public ShortVLA(int[] array)
public ShortVLA(boolean ordered, short[] array, int startIndex, int count)
ordered
- If false, methods that remove elements may change the order of other elements in the array, which avoids a
memory copy.public void add(short value)
public void addAll(ShortVLA array)
public void addAll(ShortVLA array, int offset, int length)
public void addAll(short... array)
public void addAll(short[] array, int offset, int length)
public void addAll(int[] array)
public void addRange(int start, int end)
public void addFractionRange(int start, int end, int fraction)
public short get(int index)
public void set(int index, short value)
public void incr(int index, short value)
index
- value
- public void mul(int index, short value)
public void insert(int index, short value)
public void swap(int first, int second)
public boolean contains(short value)
public int indexOf(short value)
public int lastIndexOf(short value)
public boolean removeValue(short value)
public short removeIndex(int index)
public void removeRange(int start, int end)
public boolean removeAll(ShortVLA array)
public short pop()
public short peek()
public short first()
public void clear()
public short[] shrink()
items
public short[] ensureCapacity(int additionalCapacity)
items
protected short[] resize(int newSize)
public int[] asInts()
public void sort()
public void reverse()
public void truncate(int newSize)
public short[] toArray()
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String separator)
public static ShortVLA with(short... array)
ShortVLA(short[])
Copyright © Eben Howard 2012–2022. All rights reserved.