public class ArrayListOfShorts extends Object implements RandomAccess, Cloneable, Iterable<Short>
| Modifier and Type | Field and Description |
|---|---|
protected short[] |
array |
protected int |
size |
| Constructor and Description |
|---|
ArrayListOfShorts()
Constructs an empty list with an initial capacity of ten.
|
ArrayListOfShorts(int initialCapacity)
Constructs an empty list with the specified initial capacity.
|
ArrayListOfShorts(short[] a)
Constructs a list from an array.
|
ArrayListOfShorts(short first,
short last)
Constructs a list populated with shorts in range [first, last).
|
| Modifier and Type | Method and Description |
|---|---|
ArrayListOfShorts |
add(int index,
short element)
Inserts the specified element at the specified position in this list.
|
ArrayListOfShorts |
add(short e)
Appends the specified element to the end of this list.
|
void |
addUnique(short[] arr)
Add all shorts in the specified array into this list, ignoring duplicates.
|
void |
clear()
Removes all of the elements from this list.
|
ArrayListOfShorts |
clone()
Returns a clone of this object.
|
boolean |
contains(short n)
Returns true if this list contains the specified element.
|
void |
ensureCapacity(int minCapacity)
Increases the capacity of this object, if necessary, to ensure that it can hold at least the
number of elements specified by the minimum capacity argument.
|
boolean |
equals(Object obj)
Elementwise comparison.
|
short |
get(int index)
Returns the element at the specified position in this list.
|
short[] |
getArray()
Returns the array backing this object.
|
int |
indexOf(short n)
Returns the index of the first occurrence of the specified element in this list, or -1 if this
list does not contain the element.
|
ArrayListOfShorts |
intersection(ArrayListOfShorts other)
Computes the intersection of two sorted lists of unique shorts.
|
boolean |
isEmpty()
Returns true if this list contains no elements.
|
Iterator<Short> |
iterator()
Returns an iterator for this list.
|
int |
lastIndexOf(short n)
Returns the index of the last occurrence of the specified element in this list, or -1 if this
list does not contain the element.
|
ArrayListOfShorts |
merge(ArrayListOfShorts sortedLst)
Merges two sorted (ascending order) lists into one sorted union.
|
short |
remove(int index)
Removes the element at the specified position in this list.
|
short |
set(int index,
short element)
Replaces the element at the specified position in this list with the specified element.
|
void |
setSize(int sz)
Specifies the length of this list.
|
void |
shiftLastNToTop(int n) |
int |
size()
Returns the number of elements in this list.
|
void |
sort()
Sorts this list.
|
ArrayListOfShorts |
subList(int start,
int end)
Extracts a sub-list.
|
String |
toString() |
String |
toString(int n)
Returns a string representation of the object, explicitly printing out the first n
elements of this list.
|
void |
trimToSize()
Trims the capacity of this object to be the list's current size.
|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic ArrayListOfShorts(int initialCapacity)
initialCapacity - the initial capacity of the listIllegalArgumentException - if the specified initial capacity is negativepublic ArrayListOfShorts()
public ArrayListOfShorts(short[] a)
a - source arraypublic ArrayListOfShorts(short first,
short last)
first - the smallest short in the range (inclusive)last - the largest short in the range (exclusive)public void trimToSize()
public void ensureCapacity(int minCapacity)
minCapacity - the desired minimum capacitypublic int size()
public void setSize(int sz)
public boolean isEmpty()
public boolean contains(short n)
n - element whose presence in this list is to be testedpublic int indexOf(short n)
public int lastIndexOf(short n)
public ArrayListOfShorts clone()
public short get(int index)
index - index of the element to returnpublic short set(int index,
short element)
index - index of the element to replaceelement - element to be stored at the specified positionpublic ArrayListOfShorts add(short e)
public ArrayListOfShorts add(int index, short element)
index - index at which the specified element is to be insertedelement - element to be insertedpublic short remove(int index)
index - the index of the element to be removedpublic void clear()
public short[] getArray()
public Iterator<Short> iterator()
Iterable interface; this method is not efficient because of
autoboxing.public String toString(int n)
public void sort()
public ArrayListOfShorts intersection(ArrayListOfShorts other)
other - other list to be intersected with this listpublic ArrayListOfShorts merge(ArrayListOfShorts sortedLst)
sortedLst - list to be merged into thispublic ArrayListOfShorts subList(int start, int end)
start - first index to be included in sub-listend - last index to be included in sub-liststart to endpublic void addUnique(short[] arr)
arr - array of shorts to add to this objectpublic void shiftLastNToTop(int n)
Copyright © 2018. All rights reserved.