org.javimmutable.collections.array.bit32
Class Bit32Array<T>

java.lang.Object
  extended by org.javimmutable.collections.common.AbstractJImmutableArray<T>
      extended by org.javimmutable.collections.array.bit32.Bit32Array<T>
Type Parameters:
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:
EmptyBit32Array, FullBit32Array, SingleBit32Array, StandardBit32Array

@Immutable
public abstract class Bit32Array<T>
extends AbstractJImmutableArray<T>

JImmutableArray implementation that only accepts indexes in the range [0, 31].


Constructor Summary
Bit32Array()
           
 
Method Summary
abstract  Bit32Array<T> assign(int key, T value)
          Sets the value associated with a specific index.
protected static void checkIndex(int index)
           
abstract  Bit32Array<T> delete(int key)
          Deletes the entry for the specified index (if any).
 JImmutableArray<T> deleteAll()
           
abstract  int firstIndex()
           
 T get(int index)
          Return the value associated with index or null if no value is associated.
static
<T> Bit32Array<T>
of()
           
static
<T> Bit32Array<T>
of(Indexed<T> source, int offset, int limit)
          Constructor for efficiently creating a Bit32Array with consecutive indexes of up to 32 elements from an Indexed collection.
static
<T> Bit32Array<T>
of(int index, T value)
          Creates a new Bit32Array containing exactly one element.
 
Methods inherited from class org.javimmutable.collections.common.AbstractJImmutableArray
findEntry, getMap, insert, isEmpty, iterator, keysCursor, valuesCursor
 
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
find, getValueOr, size
 
Methods inherited from interface org.javimmutable.collections.Cursorable
cursor
 

Constructor Detail

Bit32Array

public Bit32Array()
Method Detail

of

public static <T> Bit32Array<T> of()

of

public static <T> Bit32Array<T> of(int index,
                                   T value)
Creates a new Bit32Array containing exactly one element.

Type Parameters:
T -
Parameters:
index -
value -
Returns:

of

public static <T> Bit32Array<T> of(Indexed<T> source,
                                   int offset,
                                   int limit)
Constructor for efficiently creating a Bit32Array with consecutive indexes of up to 32 elements from an Indexed collection. (limit - offset) must be in the range 0 to 32 inclusive.

Type Parameters:
T -
Parameters:
source -
offset -
limit -
Returns:

assign

@Nonnull
public abstract Bit32Array<T> assign(int key,
                                             @Nullable
                                             T value)
Description copied from interface: JImmutableArray
Sets 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 new PersistentMap reflecting any changes. The original map is always left unchanged.

Parameters:
key - index
value - possibly null value
Returns:
new map reflecting the change

delete

@Nonnull
public abstract Bit32Array<T> delete(int key)
Description copied from interface: JImmutableArray
Deletes 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.

Parameters:
key - index
Returns:
same or different map depending on whether index was removed

firstIndex

public abstract int firstIndex()

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>
Overrides:
get in class AbstractJImmutableArray<T>
Parameters:
index - identifies the value to retrieve
Returns:
value associated with index or null if no value is associated

deleteAll

@Nonnull
public JImmutableArray<T> deleteAll()
Returns:
an equivalent collection with no values

checkIndex

protected static void checkIndex(int index)


Copyright © 2014 Burton Computer Corporation. All rights reserved.