Package edu.uky.ai.util
Class ImmutableArray<E>
java.lang.Object
edu.uky.ai.util.ImmutableArray<E>
- Type Parameters:
E- the type of object kept in the array
- All Implemented Interfaces:
Serializable,Iterable<E>
An array whose values cannot be modified.
- Author:
- Stephen G. Ware
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionImmutableArray(E[] array) Constructs a new immutable array which reflects the given array.ImmutableArray(Collection<E> collection, Class<E> type) Creates an immutable array that contains the elements of a collection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the array contains a given element.booleanvoidfinal Eget(int index) Returns the element at a given index.Returns the array's component type.inthashCode()intReturns the index of the first object that is equal to a given object.iterator()intsize()Returns the number of elements in the array.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
spliterator
-
Constructor Details
-
ImmutableArray
Constructs a new immutable array which reflects the given array.- Parameters:
array- the array to mirror
-
ImmutableArray
Creates an immutable array that contains the elements of a collection.- Parameters:
collection- the collection to mirrortype- the type of object kept in the array
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
size
public int size()Returns the number of elements in the array.- Returns:
- the number of elements
-
get
Returns the element at a given index.- Parameters:
index- the index in the array- Returns:
- the element at that index
-
getComponentType
Returns the array's component type.- Returns:
- the component type
-
contains
Checks if the array contains a given element.- Parameters:
element- the element to search for- Returns:
- true if the array contains an object equal to the given object, false otherwise
-
indexOf
Returns the index of the first object that is equal to a given object.- Parameters:
element- the element to search for- Returns:
- the index of that object in the array, or -1 if no such object exists
-
iterator
-
forEach
-