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(char[] a, char[] b)

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

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

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

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

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

Fill input array by zeros

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

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

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

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

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

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

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

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

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

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

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

public static byte[]
concatenate(byte[] a, byte[] 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
contains(short[] a, short n)

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

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

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

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

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

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

public static byte[]

Returns:

a new byte array containing the range given.
copyOfRange
(byte[]
the array from which the data is to be copied.
data
,
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 data array.

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

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

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

public static void
fill(byte[] array, byte value)

public static void
fill(byte[] array, int start, int finish, byte value)

public static void
fill(char[] array, char value)

public static void
fill(long[] array, long value)

public static void
fill(short[] array, short value)

public static void
fill(int[] array, int value)

public static void
fill(byte[] array, int out, byte value)

public static void
fill(int[] array, int out, int value)

public static void
fill(short[] array, int out, short value)

public static void
fill(long[] array, int out, long value)

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 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)

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(char[] a, char[] b)
areEqualback to summary
public static boolean areEqual(byte[] a, byte[] b)
areEqualback to summary
public static boolean areEqual(short[] a, short[] 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)
clearback to summary
public static void clear(byte[] array)

Fill input array by zeros

Parameters
array:byte[]

input array

cloneback to summary
public static byte[] clone(byte[] data)
cloneback to summary
public static char[] clone(char[] data)
cloneback to summary
public static byte[] clone(byte[] data, byte[] existing)
cloneback to summary
public static byte[][] clone(byte[][] data)
cloneback to summary
public static byte[][][] clone(byte[][][] data)
cloneback to summary
public static int[] clone(int[] data)
cloneback to summary
public static long[] clone(long[] data)
cloneback to summary
public static long[] clone(long[] data, long[] existing)
cloneback to summary
public static short[] clone(short[] data)
cloneback to summary
public static BigInteger[] clone(BigInteger[] 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 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.

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

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

Parameters
data: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 int[] copyOfRange(int[] data, int from, int to)
copyOfRangeback to summary
public static long[] copyOfRange(long[] data, int from, int to)
copyOfRangeback to summary
public static BigInteger[] copyOfRange(BigInteger[] data, int from, int to)
fillback to summary
public static void fill(byte[] array, byte value)
fillback to summary
public static void fill(byte[] array, int start, int finish, byte value)
fillback to summary
public static void fill(char[] array, char value)
fillback to summary
public static void fill(long[] array, long value)
fillback to summary
public static void fill(short[] array, short value)
fillback to summary
public static void fill(int[] array, int value)
fillback to summary
public static void fill(byte[] array, int out, byte value)
fillback to summary
public static void fill(int[] array, int out, int value)
fillback to summary
public static void fill(short[] array, int out, short value)
fillback to summary
public static void fill(long[] array, int out, long value)
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)
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)
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.