Class TrieArray<T>
java.lang.Object
org.javimmutable.collections.array.TrieArray<T>
- All Implemented Interfaces:
Serializable,Iterable<IMapEntry<Integer,,T>> IArray<T>,ICollection<IMapEntry<Integer,,T>> Indexed<T>,InvariantCheckable,IStreamable<IMapEntry<Integer,,T>> SplitableIterable<IMapEntry<Integer,T>>
- See Also:
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionSets the value associated with a specific index.static <T> IArrayBuilder<T> builder()voidChecks invariants of implementing class.static <T> java.util.stream.Collector<T, ?, IArray<T>> delete(int index) Deletes the entry for the specified index (if any).booleanfind(int index) Return a Holder containing the value associated wth the index or an empty Holder if no value is associated with the index.findEntry(int index) Search for an Entry within the map and return a Holder indicating if the Entry was found and, if it was found, the Entry itself.voidvoidforEach(IndexedProc1<T> proc) Visits every element in the array in order by index and passes the index and value to the provided lambda.<E extends Exception>
voidforEachThrows(IndexedProc1Throws<T, E> proc) Visits every element in the array in order by index and passes the index and value to the provided lambda.<E extends Exception>
voidforEachThrows(Proc1Throws<IMapEntry<Integer, T>, E> proc) Processes every value using the provided function.get(int index) Return the value associated with index or null if no value is associated.getMap()Creates an unmodifiable java.util.Map reflecting the values of theIMapbacking the array.intgetValueOr(int index, T defaultValue) Return the value associated with index or defaultValue if no value is associated.inthashCode()Add value to the container in some manner appropriate to the implementation.Add all values to the container in some manner appropriate to the implementation.Add all values to the container in some manner appropriate to the implementation.iterator()Overridden here to require implementations to return a SplitableIterator rather than a basic Iterator.keys()Creates an IStreamable to access all of the array's keys.static <T> IArray<T> of()intsize()Retrieve the number of values available in the container.Creates and returns a new Builder object for the same value type as this array.toString()values()Creates an IStreamable to access all of the array's values.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.javimmutable.collections.ICollection
isEmpty, isNonEmptyMethods inherited from interface org.javimmutable.collections.Indexed
prefix, reversed, transformedMethods inherited from interface org.javimmutable.collections.IStreamable
parallelStream, spliterator, streamMethods inherited from interface org.javimmutable.collections.SplitableIterable
indexedForEach, indexedForEachThrows, reduce, reduceThrows
-
Method Details
-
of
-
builder
-
collector
-
get
Description copied from interface:IArrayReturn the value associated with index or null if no value is associated. Note that if null is an acceptable value to the container then this method will be ambiguous and find() should be used instead. -
getValueOr
Description copied from interface:IArrayReturn the value associated with index or defaultValue if no value is associated. Note that if defaultValue is an acceptable value to the container then this method will be ambiguous and find() should be used instead.- Specified by:
getValueOrin interfaceIArray<T>- Parameters:
index- identifies the value to retrievedefaultValue- value to return if no entry exists for index- Returns:
- value associated with index or defaultValue if no value is associated
-
find
Description copied from interface:IArrayReturn a Holder containing the value associated wth the index or an empty Holder if no value is associated with the index. -
findEntry
Description copied from interface:IArraySearch for an Entry within the map and return a Holder indicating if the Entry was found and, if it was found, the Entry itself. -
assign
Description copied from interface:IArraySets the value associated with a specific index. Index must be non-null but value can be null. If the index already has a value in the map the old value is discarded and the new value is stored in its place. Returns a newIMapreflecting any changes. The original map is always left unchanged. -
delete
Description copied from interface:IArrayDeletes the entry for the specified index (if any). Returns a new map if the value was deleted or the current map if the index was not contained in the map. -
size
public int size()Description copied from interface:IndexedRetrieve the number of values available in the container. -
deleteAll
-
getMap
Description copied from interface:IArrayCreates an unmodifiable java.util.Map reflecting the values of theIMapbacking the array. -
insert
Description copied from interface:ICollectionAdd value to the container in some manner appropriate to the implementation. -
insertAll
Description copied from interface:ICollectionAdd all values to the container in some manner appropriate to the implementation. -
insertAll
Description copied from interface:ICollectionAdd all values to the container in some manner appropriate to the implementation. -
checkInvariants
public void checkInvariants()Description copied from interface:InvariantCheckableChecks invariants of implementing class.- Specified by:
checkInvariantsin interfaceInvariantCheckable
-
iterator
Description copied from interface:IStreamableOverridden here to require implementations to return a SplitableIterator rather than a basic Iterator. This is necessary to allow composition of new objects from methods like keys() and values().- Specified by:
iteratorin interfaceIStreamable<T>- Specified by:
iteratorin interfaceIterable<T>- Specified by:
iteratorin interfaceSplitableIterable<T>
-
keys
Description copied from interface:IArrayCreates an IStreamable to access all of the array's keys. -
values
Description copied from interface:IArrayCreates an IStreamable to access all of the array's values. -
getSpliteratorCharacteristics
public int getSpliteratorCharacteristics()- Specified by:
getSpliteratorCharacteristicsin interfaceIStreamable<T>- Returns:
- characteristics value used when creating Spliterators
-
forEach
-
forEachThrows
public <E extends Exception> void forEachThrows(@Nonnull Proc1Throws<IMapEntry<Integer, T>, throws EE> proc) Description copied from interface:SplitableIterableProcesses every value using the provided function.- Specified by:
forEachThrowsin interfaceSplitableIterable<T>- Throws:
E
-
forEach
Description copied from interface:IArrayVisits every element in the array in order by index and passes the index and value to the provided lambda. Unlike indexedForEach method the index values passed to the lambda are the actual key value in the array. -
forEachThrows
Description copied from interface:IArrayVisits every element in the array in order by index and passes the index and value to the provided lambda. Unlike indexedForEach method the index values passed to the lambda are the actual key value in the array.- Specified by:
forEachThrowsin interfaceIArray<T>- Throws:
E
-
equals
-
hashCode
public int hashCode() -
toString
-
toBuilder
Description copied from interface:IArrayCreates and returns a new Builder object for the same value type as this array.
-