Top Description Inners Fields Constructors Methods
com.google.common.primitives

public final Class Shorts

extends ShortsMethodsForWeb
Class Inheritance
Annotations
@GwtCompatible
emulated:true
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkElementIndex, .Preconditions.checkNotNull, .Preconditions.checkPositionIndexes

Static utility methods pertaining to short primitives, that are not already found in either Short or Arrays.

See the Guava User Guide article on primitive utilities.

Author
Kevin Bourrillion
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
private static class
private static class

Field Summary

Modifier and TypeField and Description
public static final int
BYTES

The number of bytes required to represent a primitive short value.

public static final short
MAX_POWER_OF_TWO

The largest power of two that can be represented as a short.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<Short>

Returns:

a list view of the array
asList
(short...
the array to back the list
backingArray
)

Returns a fixed-size list backed by the specified array, similar to Arrays#asList(Object[]).

public static short

Returns:

the short value that equals value
checkedCast
(long
any value in the range of the short type
value
)

Returns the short value that is equal to value, if possible.

public static int

Returns:

a negative value if a is less than b; a positive value if a is greater than b; or zero if they are equal
compare
(short
the first short to compare
a
,
short
the second short to compare
b
)

Compares the two specified short values.

public static short[]

Returns:

a single array containing all the values from the source arrays, in order
concat
(short[]...
zero or more short arrays
arrays
)

Returns the values from each provided array combined into a single array.

public static short
constrainToRange(short
the short value to constrain
value
,
short
the lower bound (inclusive) of the range to constrain value to
min
,
short
the upper bound (inclusive) of the range to constrain value to
max
)

Returns the value nearest to value which is within the closed range [min..max].

public static boolean

Returns:

true if array[i] == target for some value of i
contains
(short[]
an array of short values, possibly empty
array
,
short
a primitive short value
target
)

Returns true if target is present as an element anywhere in array.

public static short[]

Returns:

an array containing the values of array, with guaranteed minimum length minLength
ensureCapacity
(short[]
the 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 array, but guaranteed to be of a specified minimum length.

public static short
fromByteArray(byte[] bytes)

Returns the short value whose big-endian representation is stored in the first 2 bytes of bytes; equivalent to ByteBuffer.wrap(bytes).getShort().

public static short
fromBytes(byte b1, byte b2)

Returns the short value whose byte representation is the given 2 bytes, in big-endian order; equivalent to Shorts.fromByteArray(new byte[] {b1, b2}).

public static int

Returns:

a hash code for the value
hashCode
(short
a primitive short value
value
)

Returns a hash code for value; equal to the result of invoking ((Short) value).hashCode().

public static int

Returns:

the least index i for which array[i] == target, or -1 if no such index exists.
indexOf
(short[]
an array of short values, possibly empty
array
,
short
a primitive short value
target
)

Returns the index of the first appearance of the value target in array.

private static int
indexOf(short[] array, short target, int start, int end)

public static int
indexOf(short[]
the array to search for the sequence target
array
,
short[]
the array to search for as a sub-sequence of array
target
)

Returns the start position of the first occurrence of the specified target within array, or -1 if there is no such occurrence.

public static String
join(String
the text that should appear between consecutive values in the resulting string (but not at the start or end)
separator
,
short...
an array of short values, possibly empty
array
)

Returns a string containing the supplied short values separated by separator.

public static int

Returns:

the greatest index i for which array[i] == target, or -1 if no such index exists.
lastIndexOf
(short[]
an array of short values, possibly empty
array
,
short
a primitive short value
target
)

Returns the index of the last appearance of the value target in array.

private static int
lastIndexOf(short[] array, short target, int start, int end)

public static Comparator<short[]>
lexicographicalComparator()

Returns a comparator that compares two short arrays lexicographically.

public static short

Returns:

the value present in array that is greater than or equal to every other value in the array
max
(short...
a nonempty array of short values
array
)

Returns the greatest value present in array.

public static short

Returns:

the value present in array that is less than or equal to every other value in the array
min
(short...
a nonempty array of short values
array
)

Returns the least value present in array.

public static void
reverse(short[] array)

Reverses the elements of array.

public static void
reverse(short[] array, int fromIndex, int toIndex)

Reverses the elements of array between fromIndex inclusive and toIndex exclusive.

public static void
rotate(short[] array, int distance)

Performs a right rotation of array of "distance" places, so that the first element is moved to index "distance", and the element at index i ends up at index (distance + i) mod array.length.

public static void
rotate(short[] array, int distance, int fromIndex, int toIndex)

Performs a right rotation of array between fromIndex inclusive and toIndex exclusive.

public static short

Returns:

the same value cast to short 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 small
saturatedCast
(long
any long value
value
)

Returns the short nearest in value to value.

public static void
sortDescending(short[] array)

Sorts the elements of array in descending order.

public static void
sortDescending(short[] array, int fromIndex, int toIndex)

Sorts the elements of array between fromIndex inclusive and toIndex exclusive in descending order.

public static Converter<String, Short>
stringConverter()

Returns a serializable converter object that converts between strings and shorts using Short#decode and Short#toString().

public static short[]

Returns:

an array containing the same values as collection, in the same order, converted to primitives
toArray
(Collection<? extends Number>
a collection of Number instances
collection
)

Returns an array containing each value of collection, converted to a short value in the manner of Number#shortValue.

public static byte[]
toByteArray(short value)

Returns a big-endian representation of value in a 2-element byte array; equivalent to ByteBuffer.allocate(2).putShort(value).array().

Field Detail

BYTESback to summary
public static final int BYTES

The number of bytes required to represent a primitive short value.

Java 8+ users: use Short#BYTES instead.

MAX_POWER_OF_TWOback to summary
public static final short MAX_POWER_OF_TWO

The largest power of two that can be represented as a short.

Since
10.0

Constructor Detail

Shortsback to summary
private Shorts()

Method Detail

asListback to summary
public static List<Short> asList(short... backingArray)

Returns a fixed-size list backed by the specified array, similar to Arrays#asList(Object[]). The list supports List#set(int, Object), but any attempt to set a value to null will result in a NullPointerException.

The returned list maintains the values, but not the identities, of Short objects written to or read from it. For example, whether list.get(0) == list.get(0) is true for the returned list is unspecified.

The returned list is serializable.

Parameters
backingArray:short[]

the array to back the list

Returns:List<Short>

a list view of the array

checkedCastback to summary
public static short checkedCast(long value)

Returns the short value that is equal to value, if possible.

Parameters
value:long

any value in the range of the short type

Returns:short

the short value that equals value

Exceptions
IllegalArgumentException:
if value is greater than Short#MAX_VALUE or less than Short#MIN_VALUE
compareback to summary
public static int compare(short a, short b)

Compares the two specified short values. The sign of the value returned is the same as that of ((Short) a).compareTo(b).

Java 7+ users: this method should be treated as deprecated; use the equivalent Short#compare method instead.

Parameters
a:short

the first short to compare

b:short

the second short to compare

Returns:int

a negative value if a is less than b; a positive value if a is greater than b; or zero if they are equal

concatback to summary
public static short[] concat(short[]... arrays)

Returns the values from each provided array combined into a single array. For example, concat(new short[] {a, b}, new short[] {}, new short[] {c} returns the array {a, b, c}.

Parameters
arrays:short[][]

zero or more short arrays

Returns:short[]

a single array containing all the values from the source arrays, in order

constrainToRangeback to summary
public static short constrainToRange(short value, short min, short max)

Returns the value nearest to value which is within the closed range [min..max].

If value is within the range [min..max], value is returned unchanged. If value is less than min, min is returned, and if value is greater than max, max is returned.

Parameters
value:short

the short value to constrain

min:short

the lower bound (inclusive) of the range to constrain value to

max:short

the upper bound (inclusive) of the range to constrain value to

Exceptions
IllegalArgumentException:
if min > max
Since
21.0
containsback to summary
public static boolean contains(short[] array, short target)

Returns true if target is present as an element anywhere in array.

Parameters
array:short[]

an array of short values, possibly empty

target:short

a primitive short value

Returns:boolean

true if array[i] == target for some value of i

ensureCapacityback to summary
public static short[] ensureCapacity(short[] array, int minLength, int padding)

Returns an array containing the same values as array, but guaranteed to be of a specified minimum length. If array already has a length of at least minLength, it is returned directly. Otherwise, a new array of size minLength + padding is returned, containing the values of array, and zeroes in the remaining places.

Parameters
array:short[]

the source array

minLength:int

the minimum length the returned array must guarantee

padding:int

an extra amount to "grow" the array by if growth is necessary

Returns:short[]

an array containing the values of array, with guaranteed minimum length minLength

Exceptions
IllegalArgumentException:
if minLength or padding is negative
fromByteArrayback to summary
public static short fromByteArray(byte[] bytes)

Returns the short value whose big-endian representation is stored in the first 2 bytes of bytes; equivalent to ByteBuffer.wrap(bytes).getShort(). For example, the input byte array {0x54, 0x32} would yield the short value 0x5432.

Arguably, it's preferable to use java.nio.ByteBuffer; that library exposes much more flexibility at little cost in readability.

Annotations
@GwtIncompatible
Exceptions
IllegalArgumentException:
if bytes has fewer than 2 elements
fromBytesback to summary
public static short fromBytes(byte b1, byte b2)

Returns the short value whose byte representation is the given 2 bytes, in big-endian order; equivalent to Shorts.fromByteArray(new byte[] {b1, b2}).

Annotations
@GwtIncompatible
Since
7.0
hashCodeback to summary
public static int hashCode(short value)

Returns a hash code for value; equal to the result of invoking ((Short) value).hashCode().

Java 8+ users: use Short#hashCode(short) instead.

Parameters
value:short

a primitive short value

Returns:int

a hash code for the value

indexOfback to summary
public static int indexOf(short[] array, short target)

Returns the index of the first appearance of the value target in array.

Parameters
array:short[]

an array of short values, possibly empty

target:short

a primitive short value

Returns:int

the least index i for which array[i] == target, or -1 if no such index exists.

indexOfback to summary
private static int indexOf(short[] array, short target, int start, int end)
indexOfback to summary
public static int indexOf(short[] array, short[] target)

Returns the start position of the first occurrence of the specified target within array, or -1 if there is no such occurrence.

More formally, returns the lowest index i such that Arrays.copyOfRange(array, i, i + target.length) contains exactly the same elements as target.

Parameters
array:short[]

the array to search for the sequence target

target:short[]

the array to search for as a sub-sequence of array

joinback to summary
public static String join(String separator, short... array)

Returns a string containing the supplied short values separated by separator. For example, join("-", (short) 1, (short) 2, (short) 3) returns the string "1-2-3".

Parameters
separator:String

the text that should appear between consecutive values in the resulting string (but not at the start or end)

array:short[]

an array of short values, possibly empty

lastIndexOfback to summary
public static int lastIndexOf(short[] array, short target)

Returns the index of the last appearance of the value target in array.

Parameters
array:short[]

an array of short values, possibly empty

target:short

a primitive short value

Returns:int

the greatest index i for which array[i] == target, or -1 if no such index exists.

lastIndexOfback to summary
private static int lastIndexOf(short[] array, short target, int start, int end)
lexicographicalComparatorback to summary
public static Comparator<short[]> lexicographicalComparator()

Returns a comparator that compares two short arrays lexicographically. That is, it compares, using compare(short, short)), the first pair of values that follow any common prefix, or when one array is a prefix of the other, treats the shorter array as the lesser. For example, [] < [(short) 1] < [(short) 1, (short) 2] < [(short) 2].

The returned comparator is inconsistent with Object#equals(Object) (since arrays support only identity equality), but it is consistent with Arrays#equals(short[], short[]).

Since
2.0
maxback to summary
public static short max(short... array)

Returns the greatest value present in array.

Parameters
array:short[]

a nonempty array of short values

Returns:short

the value present in array that is greater than or equal to every other value in the array

Annotations
@GwtIncompatible:Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.
Exceptions
IllegalArgumentException:
if array is empty
minback to summary
public static short min(short... array)

Returns the least value present in array.

Parameters
array:short[]

a nonempty array of short values

Returns:short

the value present in array that is less than or equal to every other value in the array

Annotations
@GwtIncompatible:Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.
Exceptions
IllegalArgumentException:
if array is empty
reverseback to summary
public static void reverse(short[] array)

Reverses the elements of array. This is equivalent to Collections.reverse(Shorts.asList(array)), but is likely to be more efficient.

Since
23.1
reverseback to summary
public static void reverse(short[] array, int fromIndex, int toIndex)

Reverses the elements of array between fromIndex inclusive and toIndex exclusive. This is equivalent to Collections.reverse(Shorts.asList(array).subList(fromIndex, toIndex)), but is likely to be more efficient.

Exceptions
IndexOutOfBoundsException:
if fromIndex < 0, toIndex > array.length, or toIndex > fromIndex
Since
23.1
rotateback to summary
public static void rotate(short[] array, int distance)

Performs a right rotation of array of "distance" places, so that the first element is moved to index "distance", and the element at index i ends up at index (distance + i) mod array.length. This is equivalent to Collections.rotate(Shorts.asList(array), distance), but is considerably faster and avoids allocation and garbage collection.

The provided "distance" may be negative, which will rotate left.

Since
32.0.0
rotateback to summary
public static void rotate(short[] array, int distance, int fromIndex, int toIndex)

Performs a right rotation of array between fromIndex inclusive and toIndex exclusive. This is equivalent to Collections.rotate(Shorts.asList(array).subList(fromIndex, toIndex), distance), but is considerably faster and avoids allocations and garbage collection.

The provided "distance" may be negative, which will rotate left.

Exceptions
IndexOutOfBoundsException:
if fromIndex < 0, toIndex > array.length, or toIndex > fromIndex
Since
32.0.0
saturatedCastback to summary
public static short saturatedCast(long value)

Returns the short nearest in value to value.

Parameters
value:long

any long value

Returns:short

the same value cast to short 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 small

sortDescendingback to summary
public static void sortDescending(short[] array)

Sorts the elements of array in descending order.

Since
23.1
sortDescendingback to summary
public static void sortDescending(short[] array, int fromIndex, int toIndex)

Sorts the elements of array between fromIndex inclusive and toIndex exclusive in descending order.

Since
23.1
stringConverterback to summary
public static Converter<String, Short> stringConverter()

Returns a serializable converter object that converts between strings and shorts using Short#decode and Short#toString(). The returned converter throws NumberFormatException if the input string is invalid.

Warning

please see Short#decode to understand exactly how strings are parsed. For example, the string "0123" is treated as octal and converted to the value 83.

Since
16.0
toArrayback to summary
public static short[] toArray(Collection<? extends Number> collection)

Returns an array containing each value of collection, converted to a short value in the manner of Number#shortValue.

Elements are copied from the argument collection as if by collection.toArray(). Calling this method is as thread-safe as calling that method.

Parameters
collection:Collection<? extends Number>

a collection of Number instances

Returns:short[]

an array containing the same values as collection, in the same order, converted to primitives

Exceptions
NullPointerException:
if collection or any of its elements is null
Since
1.0 (parameter was Collection<Short> before 12.0)
toByteArrayback to summary
public static byte[] toByteArray(short value)

Returns a big-endian representation of value in a 2-element byte array; equivalent to ByteBuffer.allocate(2).putShort(value).array(). For example, the input value (short) 0x1234 would yield the byte array {0x12, 0x34}.

If you need to convert and concatenate several values (possibly even of different types), use a shared java.nio.ByteBuffer instance, or use com.google.common.io.ByteStreams#newDataOutput() to get a growable buffer.

Annotations
@GwtIncompatible
com.google.common.primitives back to summary

private final Enum Shorts.LexicographicalComparator

extends Enum<Shorts.LexicographicalComparator>
implements Comparator<short[]>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Field Summary

Modifier and TypeField and Description
public static final Shorts.LexicographicalComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(short[]
the first object to be compared.
left
,
short[]
the second object to be compared.
right
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static Shorts.LexicographicalComparator
public static Shorts.LexicographicalComparator[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

INSTANCEback to summary
public static final Shorts.LexicographicalComparator INSTANCE

Constructor Detail

LexicographicalComparatorback to summary
private LexicographicalComparator()

Method Detail

compareback to summary
public int compare(short[] left, short[] right)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

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 signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
left:short[]

the first object to be compared.

right:short[]

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

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.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static Shorts.LexicographicalComparator valueOf(String name)
valuesback to summary
public static Shorts.LexicographicalComparator[] values()
com.google.common.primitives back to summary

private Class Shorts.ShortArrayAsList

extends AbstractList<Short>
implements RandomAccess, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.RandomAccess
Annotations
@GwtCompatible

Field Summary

Modifier and TypeField and Description
pack-priv final short[]
pack-priv final int
private static final long
pack-priv final int
Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
pack-priv
ShortArrayAsList(short[] array)

pack-priv
ShortArrayAsList(short[] array, int start, int end)

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(Object
element whose presence in this list is to be tested
target
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.List.contains, java.util.Collection.contains.

Returns 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.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified object with this list for equality.
public Short
get(int
index of the element to return
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.
public int
hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Returns the hash code value for this list.
public int
indexOf(Object
element to search for
target
)

Overrides java.util.AbstractList.indexOf.

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Returns true if this list contains no elements.
public int
lastIndexOf(Object
element to search for
target
)

Overrides java.util.AbstractList.lastIndexOf.

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
public Short
set(int
index of the element to replace
index
,
Short
element to be stored at the specified position
element
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.
public List<Short>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Overrides java.util.AbstractList.subList.

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
pack-priv short[]
public String
toString()

Overrides java.util.AbstractCollection.toString.

Returns a string representation of this collection.
Inherited from java.util.AbstractList:
addaddaddAllcleariteratorlistIteratorlistIteratorremoveremoveRange

Field Detail

arrayback to summary
pack-priv final short[] array
endback to summary
pack-priv final int end
serialVersionUIDback to summary
private static final long serialVersionUID
startback to summary
pack-priv final int start

Constructor Detail

ShortArrayAsListback to summary
pack-priv ShortArrayAsList(short[] array)
ShortArrayAsListback to summary
pack-priv ShortArrayAsList(short[] array, int start, int end)

Method Detail

containsback to summary
public boolean contains(Object target)

Overrides java.util.AbstractCollection.contains.

Implements java.util.List.contains, java.util.Collection.contains.

Doc from java.util.List.contains.

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e).

Parameters
target:Object

element whose presence in this list is to be tested

Returns:boolean

true if this list contains the specified element

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Doc from java.util.AbstractList.equals.

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order.

Parameters
object:Object

the object to be compared for equality with this list

Returns:boolean

true if the specified object is equal to this list

Annotations
@Override
getback to summary
public Short get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Doc from java.util.AbstractList.get.

Returns the element at the specified position in this list.

Parameters
index:int

Doc from java.util.List.get.

index of the element to return

Returns:Short

Doc from java.util.List.get.

the element at the specified position in this list

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Doc from java.util.AbstractList.hashCode.

Returns the hash code value for this list.

Returns:int

the hash code value for this list

Annotations
@Override
indexOfback to summary
public int indexOf(Object target)

Overrides java.util.AbstractList.indexOf.

Implements java.util.List.indexOf.

Doc from java.util.AbstractList.indexOf.

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 i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
target:Object

Doc from java.util.List.indexOf.

element to search for

Returns:int

Doc from java.util.List.indexOf.

the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Doc from java.util.List.isEmpty.

Returns true if this list contains no elements.

Returns:boolean

true if this list contains no elements

Annotations
@Override
lastIndexOfback to summary
public int lastIndexOf(Object target)

Overrides java.util.AbstractList.lastIndexOf.

Implements java.util.List.lastIndexOf.

Doc from java.util.AbstractList.lastIndexOf.

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 i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
target:Object

Doc from java.util.List.lastIndexOf.

element to search for

Returns:int

Doc from java.util.List.lastIndexOf.

the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element

Annotations
@Override
setback to summary
public Short set(int index, Short element)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Doc from java.util.AbstractList.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

Doc from java.util.List.set.

index of the element to replace

element:Short

Doc from java.util.List.set.

element to be stored at the specified position

Returns:Short

Doc from java.util.List.set.

the element previously at the specified position

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

Annotations
@Override
subListback to summary
public List<Short> subList(int fromIndex, int toIndex)

Overrides java.util.AbstractList.subList.

Implements java.util.List.subList.

Doc from java.util.AbstractList.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

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:

list.subList(from, to).clear();
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.)

Parameters
fromIndex:int

Doc from java.util.List.subList.

low endpoint (inclusive) of the subList

toIndex:int

Doc from java.util.List.subList.

high endpoint (exclusive) of the subList

Returns:List<Short>

Doc from java.util.List.subList.

a view of the specified range within this list

Annotations
@Override
toShortArrayback to summary
pack-priv short[] toShortArray()
toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Doc from java.util.AbstractCollection.toString.

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 ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this collection

Annotations
@Override
com.google.common.primitives back to summary

private final Class Shorts.ShortConverter

extends Converter<String, Short>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
pack-priv static final Converter<String, Short>
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected String
doBackward(Short
the instance to convert; will never be null
value
)

Implements abstract com.google.common.base.Converter.doBackward.

Returns a representation of b as an instance of type A.
protected Short
doForward(String
the instance to convert; will never be null
value
)

Implements abstract com.google.common.base.Converter.doForward.

Returns a representation of a as an instance of type B.
private Object
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from com.google.common.base.Converter:
andThenapplyconvertconvertAllequalsfromidentityreverse

Field Detail

INSTANCEback to summary
pack-priv static final Converter<String, Short> INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

ShortConverterback to summary
private ShortConverter()

Method Detail

doBackwardback to summary
protected String doBackward(Short value)

Implements abstract com.google.common.base.Converter.doBackward.

Doc from com.google.common.base.Converter.doBackward.

Returns a representation of b as an instance of type A. If b cannot be converted, an unchecked exception (such as IllegalArgumentException) should be thrown.

Parameters
value:Short

the instance to convert; will never be null

Returns:String

the converted instance; must not be null

Annotations
@Override
doForwardback to summary
protected Short doForward(String value)

Implements abstract com.google.common.base.Converter.doForward.

Doc from com.google.common.base.Converter.doForward.

Returns a representation of a as an instance of type B. If a cannot be converted, an unchecked exception (such as IllegalArgumentException) should be thrown.

Parameters
value:String

the instance to convert; will never be null

Returns:Short

the converted instance; must not be null

Annotations
@Override
readResolveback to summary
private Object readResolve()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override