org.javimmutable.collections.common
Class AbstractJImmutableArray<T>

java.lang.Object
  extended by org.javimmutable.collections.common.AbstractJImmutableArray<T>
All Implemented Interfaces:
Iterable<JImmutableMap.Entry<Integer,T>>, Cursorable<JImmutableMap.Entry<Integer,T>>, Indexed<T>, Insertable<JImmutableMap.Entry<Integer,T>>, JImmutableArray<T>
Direct Known Subclasses:
Bit32Array, TrieArray

@Immutable
public abstract class AbstractJImmutableArray<T>
extends Object
implements JImmutableArray<T>


Constructor Summary
AbstractJImmutableArray()
           
 
Method Summary
 Holder<JImmutableMap.Entry<Integer,T>> findEntry(int key)
          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.
 T get(int index)
          Return the value associated with index or null if no value is associated.
 Map<Integer,T> getMap()
          Creates an unmodifiable java.util.Map reflecting the values of this PersistentMap.
 Insertable<JImmutableMap.Entry<Integer,T>> insert(JImmutableMap.Entry<Integer,T> e)
          Adds the key/value pair to this map.
 boolean isEmpty()
           
 Iterator<JImmutableMap.Entry<Integer,T>> iterator()
           
 Cursor<Integer> keysCursor()
          Creates a Cursor to access all of the Map's keys.
 Cursor<T> valuesCursor()
          Creates a Cursor to access all of the Map's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.javimmutable.collections.JImmutableArray
assign, delete, deleteAll, find, getValueOr, size
 
Methods inherited from interface org.javimmutable.collections.Cursorable
cursor
 

Constructor Detail

AbstractJImmutableArray

public AbstractJImmutableArray()
Method Detail

get

@Nullable
public T get(int index)
Description copied from interface: JImmutableArray
Return 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.

Specified by:
get in interface Indexed<T>
Specified by:
get in interface JImmutableArray<T>
Parameters:
index - identifies the value to retrieve
Returns:
value associated with index or null if no value is associated

findEntry

@Nonnull
public Holder<JImmutableMap.Entry<Integer,T>> findEntry(int key)
Description copied from interface: JImmutableArray
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.

Specified by:
findEntry in interface JImmutableArray<T>
Parameters:
key - index to search for
Returns:
empty Holder if not found, otherwise filled Holder with Entry

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface JImmutableArray<T>
Returns:
true only if list contains no values

insert

@Nonnull
public Insertable<JImmutableMap.Entry<Integer,T>> insert(@Nullable
                                                                 JImmutableMap.Entry<Integer,T> e)
Adds the key/value pair to this map. Any value already existing for the specified key is replaced with the new value.

Specified by:
insert in interface Insertable<JImmutableMap.Entry<Integer,T>>
Parameters:
e -
Returns:

keysCursor

@Nonnull
public Cursor<Integer> keysCursor()
Description copied from interface: JImmutableArray
Creates a Cursor to access all of the Map's keys.

Specified by:
keysCursor in interface JImmutableArray<T>
Returns:

valuesCursor

@Nonnull
public Cursor<T> valuesCursor()
Description copied from interface: JImmutableArray
Creates a Cursor to access all of the Map's values.

Specified by:
valuesCursor in interface JImmutableArray<T>
Returns:

iterator

public Iterator<JImmutableMap.Entry<Integer,T>> iterator()
Specified by:
iterator in interface Iterable<JImmutableMap.Entry<Integer,T>>

getMap

@Nonnull
public Map<Integer,T> getMap()
Description copied from interface: JImmutableArray
Creates an unmodifiable java.util.Map reflecting the values of this PersistentMap.

Specified by:
getMap in interface JImmutableArray<T>
Returns:
Map view of this PersistentMap


Copyright © 2014 Burton Computer Corporation. All rights reserved.