short primitives, that are not already found in
either Short or Arrays.
See the Guava User Guide article on primitive utilities.
| Modifier and Type | Class and Description |
|---|---|
| private static enum | |
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | BYTES
The number of bytes required to represent a primitive |
| public static final short | MAX_POWER_OF_TWO
The largest power of two that can be represented as a |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static List | Returns: a list view of the arraythe array to back the list backingArray)Returns a fixed-size list backed by the specified array, similar to |
| public static short | Returns: theshort value that equals valueany value in the range of the value)short typeReturns the |
| public static int | Returns: a negative value ifa is less than b; a positive value if a is
greater than b; or zero if they are equalthe first a, short short to comparethe second b)short to compareCompares the two specified |
| public static short[] | Returns: a single array containing all the values from the source arrays, in orderzero or more arrays)short arraysReturns the values from each provided array combined into a single array. |
| public static short | constrainToRange(short
the value, short short value to constrainthe lower bound (inclusive) of the range to constrain min, short value tothe upper bound (inclusive) of the range to constrain max)value toReturns the value nearest to |
| public static boolean | Returns: true if array[i] == target for some value of ian array of array, short short values, possibly emptya primitive target)short valueReturns |
| public static short[] | Returns: an array containing the values ofarray, with guaranteed minimum length minLengththe source array array, int the minimum length the returned array must guarantee minLength, int an extra amount to "grow" the array by if growth is necessary padding)Returns an array containing the same values as |
| public static short | fromByteArray(byte[] bytes)
Returns the |
| public static short | fromBytes(byte b1, byte b2)
Returns the |
| public static int | Returns: a hash code for the valuea primitive value)short valueReturns a hash code for |
| public static int | Returns: the least indexi for which array[i] == target, or -1 if no
such index exists.an array of array, short short values, possibly emptya primitive target)short valueReturns the index of the first appearance of the value |
| private static int | |
| public static int | indexOf(short[]
the array to search for the sequence array, short[] targetthe array to search for as a sub-sequence of target)arrayReturns the start position of the first occurrence of the specified |
| public static String | |
| public static int | Returns: the greatest indexi for which array[i] == target, or -1 if no
such index exists.an array of array, short short values, possibly emptya primitive target)short valueReturns the index of the last appearance of the value |
| private static int | |
| public static Comparator | |
| public static short | Returns: the value present inarray that is greater than or equal to every other value
in the arraya nonempty array of array)short valuesReturns the greatest value present in |
| public static short | Returns: the value present inarray that is less than or equal to every other value in
the arraya nonempty array of array)short valuesReturns the least value present in |
| public static void | |
| public static void | reverse(short[] array, int fromIndex, int toIndex)
Reverses the elements of |
| public static void | rotate(short[] array, int distance)
Performs a right rotation of |
| public static void | rotate(short[] array, int distance, int fromIndex, int toIndex)
Performs a right rotation of |
| public static short | Returns: the same value cast toshort if it is in the range of the short type,
Short#MAX_VALUE if it is too large, or Short#MIN_VALUE if it is too smallany value)long valueReturns the |
| public static void | |
| public static void | sortDescending(short[] array, int fromIndex, int toIndex)
Sorts the elements of |
| public static Converter | stringConverter()
Returns a serializable converter object that converts between strings and shorts using |
| public static short[] | Returns: an array containing the same values ascollection, in the same order, converted
to primitivesa collection of collection)Number instancesReturns an array containing each value of |
| public static byte[] | toByteArray(short value)
Returns a big-endian representation of |
| BYTES | back to summary |
|---|---|
| public static final int BYTES The number of bytes required to represent a primitive Java 8+ users: use | |
| MAX_POWER_OF_TWO | back to summary |
|---|---|
| public static final short MAX_POWER_OF_TWO The largest power of two that can be represented as a
| |
| Shorts | back to summary |
|---|---|
| private Shorts() | |
| asList | back to summary |
|---|---|
| public static List Returns a fixed-size list backed by the specified array, similar to The returned list maintains the values, but not the identities, of The returned list is serializable. | |
| checkedCast | back to summary |
|---|---|
| public static short checkedCast(long value) Returns the
| |
| compare | back to summary |
|---|---|
| public static int compare(short a, short b) Compares the two specified Java 7+ users: this method should be treated as deprecated; use the equivalent
| |
| concat | back to summary |
|---|---|
| public static short[] concat(short[]... arrays) Returns the values from each provided array combined into a single array. For example,
| |
| constrainToRange | back to summary |
|---|---|
| public static short constrainToRange(short value, short min, short max) Returns the value nearest to If
| |
| contains | back to summary |
|---|---|
| public static boolean contains(short[] array, short target) Returns
| |
| ensureCapacity | back to summary |
|---|---|
| public static short[] ensureCapacity(short[] array, int minLength, int padding) Returns an array containing the same values as
| |
| fromByteArray | back to summary |
|---|---|
| public static short fromByteArray(byte[] bytes) Returns the Arguably, it's preferable to use
| |
| fromBytes | back to summary |
|---|---|
| public static short fromBytes(byte b1, byte b2) Returns the
| |
| hashCode | back to summary |
|---|---|
| public static int hashCode(short value) Returns a hash code for Java 8+ users: use
| |
| indexOf | back to summary |
|---|---|
| public static int indexOf(short[] array, short target) Returns the index of the first appearance of the value
| |
| indexOf | back to summary |
|---|---|
| private static int indexOf(short[] array, short target, int start, int end) | |
| indexOf | back to summary |
|---|---|
| public static int indexOf(short[] array, short[] target) Returns the start position of the first occurrence of the specified More formally, returns the lowest index
| |
| join | back to summary |
|---|---|
| public static String join(String separator, short... array) Returns a string containing the supplied
| |
| lastIndexOf | back to summary |
|---|---|
| public static int lastIndexOf(short[] array, short target) Returns the index of the last appearance of the value
| |
| lastIndexOf | back to summary |
|---|---|
| private static int lastIndexOf(short[] array, short target, int start, int end) | |
| lexicographicalComparator | back to summary |
|---|---|
| public static Comparator Returns a comparator that compares two The returned comparator is inconsistent with
| |
| max | back to summary |
|---|---|
| public static short max(short... array) Returns the greatest value present in
| |
| min | back to summary |
|---|---|
| public static short min(short... array) Returns the least value present in
| |
| reverse | back to summary |
|---|---|
| public static void reverse(short[] array) Reverses the elements of
| |
| reverse | back to summary |
|---|---|
| public static void reverse(short[] array, int fromIndex, int toIndex) Reverses the elements of
| |
| rotate | back to summary |
|---|---|
| public static void rotate(short[] array, int distance) Performs a right rotation of The provided "distance" may be negative, which will rotate left.
| |
| rotate | back to summary |
|---|---|
| public static void rotate(short[] array, int distance, int fromIndex, int toIndex) Performs a right rotation of The provided "distance" may be negative, which will rotate left.
| |
| saturatedCast | back to summary |
|---|---|
| public static short saturatedCast(long value) Returns the
| |
| sortDescending | back to summary |
|---|---|
| public static void sortDescending(short[] array) Sorts the elements of
| |
| sortDescending | back to summary |
|---|---|
| public static void sortDescending(short[] array, int fromIndex, int toIndex) Sorts the elements of
| |
| stringConverter | back to summary |
|---|---|
| public static Converter Returns a serializable converter object that converts between strings and shorts using Warning please see
| |
| toArray | back to summary |
|---|---|
| public static short[] toArray(Collection<? extends Number> collection) Returns an array containing each value of Elements are copied from the argument collection as if by
| |
| toByteArray | back to summary |
|---|---|
| public static byte[] toByteArray(short value) Returns a big-endian representation of If you need to convert and concatenate several values (possibly even of different types),
use a shared
| |
| Modifier and Type | Field and Description |
|---|---|
| public static final Shorts. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(short[]
the first object to be compared. left, short[] the second object to be compared. right)Implements java. |
| public String | toString()
Overrides java. |
| public static Shorts. | |
| public static Shorts. |
| INSTANCE | back to summary |
|---|---|
| public static final Shorts. | |
| LexicographicalComparator | back to summary |
|---|---|
| private LexicographicalComparator() | |
| compare | back to summary |
|---|---|
| public int compare(short[] left, short[] right) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists. | |
| valueOf | back to summary |
|---|---|
| public static Shorts. | |
| values | back to summary |
|---|---|
| public static Shorts. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final short[] | |
| pack-priv final int | |
| private static final long | |
| pack-priv final int |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | contains(Object
element whose presence in this list is to be tested target)Overrides java. Implements java. true if this list contains the specified element.
|
| public boolean | equals(Object
the object to be compared for equality with this list object)Overrides java. Implements java. |
| public Short | get(int
index of the element to return index)Implements abstract java. Implements java. |
| public int | hashCode()
Overrides java. Implements java. |
| public int | indexOf(Object
element to search for target)Overrides java. Implements java. |
| public boolean | isEmpty()
Overrides java. Implements java. true if this list contains no elements.
|
| public int | lastIndexOf(Object
element to search for target)Overrides java. Implements java. |
| public Short | set(int
index of the element to replace index, Short element to be stored at the specified position element)Overrides java. Implements java. |
| public int | size()
Implements abstract java. Implements java. |
| public List | subList(int
low endpoint (inclusive) of the subList fromIndex, int high endpoint (exclusive) of the subList toIndex)Overrides java. Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| pack-priv short[] | |
| public String | toString()
Overrides java. |
| array | back to summary |
|---|---|
| pack-priv final short[] array | |
| end | back to summary |
|---|---|
| pack-priv final int end | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| start | back to summary |
|---|---|
| pack-priv final int start | |
| ShortArrayAsList | back to summary |
|---|---|
| pack-priv ShortArrayAsList(short[] array) | |
| ShortArrayAsList | back to summary |
|---|---|
| pack-priv ShortArrayAsList(short[] array, int start, int end) | |
| contains | back to summary |
|---|---|
| public boolean contains(Object target) Overrides java. Implements java. Doc from java. Returns | |
| equals | back to summary |
|---|---|
| public boolean equals(Object object) Overrides java. Implements java. Doc from java. Compares the specified object with this list for equality. Returns
| |
| get | back to summary |
|---|---|
| public Short get(int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements java. Doc from java. Returns the hash code value for this list.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(Object target) Overrides java. Implements java. Doc from java. Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides java. Implements java. Doc from java. Returns
| |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(Object target) Overrides java. Implements java. Doc from java. Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the highest index
| |
| set | back to summary |
|---|---|
| public Short set(int index, Short element) Overrides java. Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| subList | back to summary |
|---|---|
| public List Overrides java. Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
| |
| toShortArray | back to summary |
|---|---|
| pack-priv short[] toShortArray() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of this collection. The string
representation consists of a list of the collection's elements in the
order they are returned by its iterator, enclosed in square brackets
( | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv static final Converter | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| protected String | doBackward(Short
the instance to convert; will never be null value)Implements abstract com. b as an instance of type A.
|
| protected Short | doForward(String
the instance to convert; will never be null value)Implements abstract com. a as an instance of type B.
|
| private Object | |
| public String |
| INSTANCE | back to summary |
|---|---|
| pack-priv static final Converter<String, Short> INSTANCE | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| ShortConverter | back to summary |
|---|---|
| private ShortConverter() | |
| doBackward | back to summary |
|---|---|
| protected String doBackward(Short value) Implements abstract com. Doc from com. Returns a representation of | |
| doForward | back to summary |
|---|---|
| protected Short doForward(String value) Implements abstract com. Doc from com. Returns a representation of | |
| readResolve | back to summary |
|---|---|
| private Object readResolve() | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |