Top Description Inners Constructors Methods
org.bouncycastle.util

public final Class Arrays

extends Object
Class Inheritance
Imports
java.math.BigInteger, java.util.NoSuchElementException

General array utilities.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Arrays.Iterator<T>

Iterator backed by a specific array.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static byte[]
append(byte[] a, byte b)

public static short[]
append(short[] a, short b)

public static int[]
append(int[] a, int b)

public static String[]
public static boolean
areAllZeroes(byte[] buf, int off, int len)

public static boolean
areEqual(boolean[] a, boolean[] b)

public static boolean
areEqual(byte[] a, byte[] b)

public static boolean
areEqual(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex)

public static boolean
areEqual(char[] a, char[] b)

public static boolean
areEqual(int[] a, int[] b)

public static boolean
areEqual(long[] a, long[] b)

public static boolean
public static boolean
areEqual(short[] a, short[] b)

public static void
clear(byte[]
input array
data
)

Fill input array by zeros

public static void
clear(int[] data)

public static boolean[]
clone(boolean[] data)

public static byte[]
clone(byte[] data)

public static char[]
clone(char[] data)

public static int[]
clone(int[] data)

public static long[]
clone(long[] data)

public static short[]
clone(short[] data)

public static BigInteger[]
clone(BigInteger[] data)

public static byte[]
clone(byte[] data, byte[] existing)

public static long[]
clone(long[] data, long[] existing)

public static byte[][]
clone(byte[][] data)

public static byte[][][]
clone(byte[][][] data)

public static int
compareUnsigned(byte[] a, byte[] b)

public static byte[]
concatenate(byte[] a, byte[] b)

public static short[]
concatenate(short[] a, short[] b)

public static byte[]
concatenate(byte[] a, byte[] b, byte[] c)

public static byte[]
concatenate(byte[] a, byte[] b, byte[] c, byte[] d)

public static byte[]
concatenate(byte[][] arrays)

public static int[]
concatenate(int[] a, int[] b)

public static boolean

Returns:

true if arrays equal, false otherwise.
constantTimeAreEqual
(byte[]
first array
expected
,
byte[]
second array
supplied
)

A constant time equals comparison - does not terminate early if test will fail.

public static boolean
constantTimeAreEqual(int len, byte[] a, int aOff, byte[] b, int bOff)

public static boolean

Returns:

true if arrays equal, false otherwise.
constantTimeAreEqual
(char[]
first array
expected
,
char[]
second array
supplied
)

A constant time equals comparison - does not terminate early if comparison fails.

public static boolean
contains(boolean[] a, boolean val)

public static boolean
contains(byte[] a, byte val)

public static boolean
contains(char[] a, char val)

public static boolean
contains(int[] a, int val)

public static boolean
contains(long[] a, long val)

public static boolean
contains(short[] a, short val)

public static boolean[]
copyOf(boolean[] original, int newLength)

public static byte[]
copyOf(byte[] original, int newLength)

public static char[]
copyOf(char[] original, int newLength)

public static int[]
copyOf(int[] original, int newLength)

public static long[]
copyOf(long[] original, int newLength)

public static short[]
copyOf(short[] original, int newLength)

public static BigInteger[]
copyOf(BigInteger[] original, int newLength)

public static boolean[]
copyOfRange(boolean[] original, int from, int to)

public static byte[]

Returns:

a new byte array containing the range given.
copyOfRange
(byte[]
the array from which the data is to be copied.
original
,
int
the start index at which the copying should take place.
from
,
int
the final index of the range (exclusive).
to
)

Make a copy of a range of bytes from the passed in array.

public static char[]
copyOfRange(char[] original, int from, int to)

public static int[]
copyOfRange(int[] original, int from, int to)

public static long[]
copyOfRange(long[] original, int from, int to)

public static short[]
copyOfRange(short[] original, int from, int to)

public static BigInteger[]
copyOfRange(BigInteger[] original, int from, int to)

public static void
fill(boolean[] a, boolean val)

public static void
fill(boolean[] a, int fromIndex, int toIndex, boolean val)

public static void
fill(byte[] a, byte val)

public static void
fill(byte[] a, int fromIndex, int toIndex, byte val)

public static void
fill(char[] a, char val)

public static void
fill(char[] a, int fromIndex, int toIndex, char val)

public static void
fill(int[] a, int val)

public static void
fill(int[] a, int fromIndex, int toIndex, int val)

public static void
fill(long[] a, long val)

public static void
fill(long[] a, int fromIndex, int toIndex, long val)

public static void
fill(Object[] a, Object val)

public static void
fill(Object[] a, int fromIndex, int toIndex, Object val)

public static void
fill(short[] a, short val)

public static void
fill(short[] a, int fromIndex, int toIndex, short val)

private static int
getLength(int from, int to)

public static int
hashCode(byte[] data)

public static int
hashCode(byte[] data, int off, int len)

public static int
hashCode(char[] data)

public static int
hashCode(int[][] ints)

public static int
hashCode(int[] data)

public static int
hashCode(int[] data, int off, int len)

public static int
hashCode(long[] data)

public static int
hashCode(long[] data, int off, int len)

public static int
hashCode(short[][][] shorts)

public static int
hashCode(short[][] shorts)

public static int
hashCode(short[] data)

public static int
hashCode(Object[] data)

public static boolean
public static boolean
isNullOrEmpty(byte[] array)

public static boolean
isNullOrEmpty(int[] array)

public static boolean
public static byte[]
prepend(byte[] a, byte b)

public static short[]
prepend(short[] a, short b)

public static int[]
prepend(int[] a, int b)

public static byte[]
reverse(byte[] a)

public static int[]
reverse(int[] a)

public static void
reverse(byte[] input, byte[] output)

public static byte[]
reverseInPlace(byte[] a)

public static void
reverseInPlace(byte[] a, int aOff, int aLen)

public static short[]
reverseInPlace(short[] a)

public static int[]
reverseInPlace(int[] a)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Arraysback to summary
private Arrays()

Method Detail

appendback to summary
public static byte[] append(byte[] a, byte b)
appendback to summary
public static short[] append(short[] a, short b)
appendback to summary
public static int[] append(int[] a, int b)
appendback to summary
public static String[] append(String[] a, String b)
areAllZeroesback to summary
public static boolean areAllZeroes(byte[] buf, int off, int len)
areEqualback to summary
public static boolean areEqual(boolean[] a, boolean[] b)
areEqualback to summary
public static boolean areEqual(byte[] a, byte[] b)
areEqualback to summary
public static boolean areEqual(byte[] a, int aFromIndex, int aToIndex, byte[] b, int bFromIndex, int bToIndex)
areEqualback to summary
public static boolean areEqual(char[] a, char[] b)
areEqualback to summary
public static boolean areEqual(int[] a, int[] b)
areEqualback to summary
public static boolean areEqual(long[] a, long[] b)
areEqualback to summary
public static boolean areEqual(Object[] a, Object[] b)
areEqualback to summary
public static boolean areEqual(short[] a, short[] b)
clearback to summary
public static void clear(byte[] data)

Fill input array by zeros

Parameters
data:byte[]

input array

clearback to summary
public static void clear(int[] data)
cloneback to summary
public static boolean[] clone(boolean[] data)
cloneback to summary
public static byte[] clone(byte[] data)
cloneback to summary
public static char[] clone(char[] data)
cloneback to summary
public static int[] clone(int[] data)
cloneback to summary
public static long[] clone(long[] data)
cloneback to summary
public static short[] clone(short[] data)
cloneback to summary
public static BigInteger[] clone(BigInteger[] data)
cloneback to summary
public static byte[] clone(byte[] data, byte[] existing)
cloneback to summary
public static long[] clone(long[] data, long[] existing)
cloneback to summary
public static byte[][] clone(byte[][] data)
cloneback to summary
public static byte[][][] clone(byte[][][] data)
compareUnsignedback to summary
public static int compareUnsigned(byte[] a, byte[] b)
concatenateback to summary
public static byte[] concatenate(byte[] a, byte[] b)
concatenateback to summary
public static short[] concatenate(short[] a, short[] b)
concatenateback to summary
public static byte[] concatenate(byte[] a, byte[] b, byte[] c)
concatenateback to summary
public static byte[] concatenate(byte[] a, byte[] b, byte[] c, byte[] d)
concatenateback to summary
public static byte[] concatenate(byte[][] arrays)
concatenateback to summary
public static int[] concatenate(int[] a, int[] b)
constantTimeAreEqualback to summary
public static boolean constantTimeAreEqual(byte[] expected, byte[] supplied)

A constant time equals comparison - does not terminate early if test will fail. For best results always pass the expected value as the first parameter.

Parameters
expected:byte[]

first array

supplied:byte[]

second array

Returns:boolean

true if arrays equal, false otherwise.

constantTimeAreEqualback to summary
public static boolean constantTimeAreEqual(int len, byte[] a, int aOff, byte[] b, int bOff)
constantTimeAreEqualback to summary
public static boolean constantTimeAreEqual(char[] expected, char[] supplied)

A constant time equals comparison - does not terminate early if comparison fails. For best results always pass the expected value as the first parameter.

Parameters
expected:char[]

first array

supplied:char[]

second array

Returns:boolean

true if arrays equal, false otherwise.

containsback to summary
public static boolean contains(boolean[] a, boolean val)
containsback to summary
public static boolean contains(byte[] a, byte val)
containsback to summary
public static boolean contains(char[] a, char val)
containsback to summary
public static boolean contains(int[] a, int val)
containsback to summary
public static boolean contains(long[] a, long val)
containsback to summary
public static boolean contains(short[] a, short val)
copyOfback to summary
public static boolean[] copyOf(boolean[] original, int newLength)
copyOfback to summary
public static byte[] copyOf(byte[] original, int newLength)
copyOfback to summary
public static char[] copyOf(char[] original, int newLength)
copyOfback to summary
public static int[] copyOf(int[] original, int newLength)
copyOfback to summary
public static long[] copyOf(long[] original, int newLength)
copyOfback to summary
public static short[] copyOf(short[] original, int newLength)
copyOfback to summary
public static BigInteger[] copyOf(BigInteger[] original, int newLength)
copyOfRangeback to summary
public static boolean[] copyOfRange(boolean[] original, int from, int to)
copyOfRangeback to summary
public static byte[] copyOfRange(byte[] original, int from, int to)

Make a copy of a range of bytes from the passed in array. The range can extend beyond the end of the input array, in which case the returned array will be padded with zeroes.

Parameters
original:byte[]

the array from which the data is to be copied.

from:int

the start index at which the copying should take place.

to:int

the final index of the range (exclusive).

Returns:byte[]

a new byte array containing the range given.

copyOfRangeback to summary
public static char[] copyOfRange(char[] original, int from, int to)
copyOfRangeback to summary
public static int[] copyOfRange(int[] original, int from, int to)
copyOfRangeback to summary
public static long[] copyOfRange(long[] original, int from, int to)
copyOfRangeback to summary
public static short[] copyOfRange(short[] original, int from, int to)
copyOfRangeback to summary
public static BigInteger[] copyOfRange(BigInteger[] original, int from, int to)
fillback to summary
public static void fill(boolean[] a, boolean val)
fillback to summary
public static void fill(boolean[] a, int fromIndex, int toIndex, boolean val)
fillback to summary
public static void fill(byte[] a, byte val)
fillback to summary
public static void fill(byte[] a, int fromIndex, int toIndex, byte val)
fillback to summary
public static void fill(char[] a, char val)
fillback to summary
public static void fill(char[] a, int fromIndex, int toIndex, char val)
fillback to summary
public static void fill(int[] a, int val)
fillback to summary
public static void fill(int[] a, int fromIndex, int toIndex, int val)
fillback to summary
public static void fill(long[] a, long val)
fillback to summary
public static void fill(long[] a, int fromIndex, int toIndex, long val)
fillback to summary
public static void fill(Object[] a, Object val)
fillback to summary
public static void fill(Object[] a, int fromIndex, int toIndex, Object val)
fillback to summary
public static void fill(short[] a, short val)
fillback to summary
public static void fill(short[] a, int fromIndex, int toIndex, short val)
getLengthback to summary
private static int getLength(int from, int to)
hashCodeback to summary
public static int hashCode(byte[] data)
hashCodeback to summary
public static int hashCode(byte[] data, int off, int len)
hashCodeback to summary
public static int hashCode(char[] data)
hashCodeback to summary
public static int hashCode(int[][] ints)
hashCodeback to summary
public static int hashCode(int[] data)
hashCodeback to summary
public static int hashCode(int[] data, int off, int len)
hashCodeback to summary
public static int hashCode(long[] data)
hashCodeback to summary
public static int hashCode(long[] data, int off, int len)
hashCodeback to summary
public static int hashCode(short[][][] shorts)
hashCodeback to summary
public static int hashCode(short[][] shorts)
hashCodeback to summary
public static int hashCode(short[] data)
hashCodeback to summary
public static int hashCode(Object[] data)
isNullOrContainsNullback to summary
public static boolean isNullOrContainsNull(Object[] array)
isNullOrEmptyback to summary
public static boolean isNullOrEmpty(byte[] array)
isNullOrEmptyback to summary
public static boolean isNullOrEmpty(int[] array)
isNullOrEmptyback to summary
public static boolean isNullOrEmpty(Object[] array)
prependback to summary
public static byte[] prepend(byte[] a, byte b)
prependback to summary
public static short[] prepend(short[] a, short b)
prependback to summary
public static int[] prepend(int[] a, int b)
reverseback to summary
public static byte[] reverse(byte[] a)
reverseback to summary
public static int[] reverse(int[] a)
reverseback to summary
public static void reverse(byte[] input, byte[] output)
reverseInPlaceback to summary
public static byte[] reverseInPlace(byte[] a)
reverseInPlaceback to summary
public static void reverseInPlace(byte[] a, int aOff, int aLen)
reverseInPlaceback to summary
public static short[] reverseInPlace(short[] a)
reverseInPlaceback to summary
public static int[] reverseInPlace(int[] a)
org.bouncycastle.util back to summary

public Class Arrays.Iterator<T>

extends Object
implements Iterator<T>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Iterator backed by a specific array.

Field Summary

Modifier and TypeField and Description
private final T[]
private int

Constructor Summary

AccessConstructor and Description
public
Iterator(T[]
array backing the iterator.
dataArray
)

Base constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.
public T
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.
public void
remove()

Overrides default java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation).
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dataArrayback to summary
private final T[] dataArray
positionback to summary
private int position

Constructor Detail

Iteratorback to summary
public Iterator(T[] dataArray)

Base constructor.

Note

the array is not cloned, changes to it will affect the values returned by next().

Parameters
dataArray:T[]

array backing the iterator.

Method Detail

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

nextback to summary
public T next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:T

the next element in the iteration

removeback to summary
public void remove()

Overrides default java.util.Iterator.remove.

Doc from java.util.Iterator.remove.

Removes from the underlying collection the last element returned by this iterator (optional operation). This method can be called only once per call to next.

The behavior of an iterator is unspecified if the underlying collection is modified while the iteration is in progress in any way other than by calling this method, unless an overriding class has specified a concurrent modification policy.

The behavior of an iterator is unspecified if this method is called after a call to the forEachRemaining method.