org.javimmutable.collections
Interface JImmutableList<T>

Type Parameters:
T -
All Superinterfaces:
Cursorable<T>, Indexed<T>, Insertable<T>, Iterable<T>
All Known Subinterfaces:
JImmutableRandomAccessList<T>
All Known Implementing Classes:
JImmutableArrayList, JImmutableTreeList

@Immutable
public interface JImmutableList<T>
extends Insertable<T>, Indexed<T>, Cursorable<T>, Iterable<T>

Interface for containers that store items in list form with individual items available for get() and assign() using their indexes. Items inserted into the list are always added at either the front or the end of the list and indexes of items are always in the range 0 through size() - 1.


Nested Class Summary
static interface JImmutableList.Builder<T>
           
 
Method Summary
 JImmutableList<T> assign(int index, T value)
          Replaces the value at the specified index (which must be within current bounds of the list) with the new value.
 JImmutableList<T> deleteAll()
           
 JImmutableList<T> deleteFirst()
          Removes the first value from the list and reduces size by 1.
 JImmutableList<T> deleteLast()
          Removes the last value from the list and reduces size by 1.
 T get(int index)
          Retrieves the value at the specified index (which must be within the bounds of the list).
 List<T> getList()
          Returns an unmodifiable List implementation backed by this list.
 JImmutableList<T> insert(Iterable<? extends T> values)
          Adds the values to the end of the list in the same order they appear in the Iterable.
 JImmutableList<T> insert(T value)
          Adds a value to the end of the list.
 JImmutableList<T> insertFirst(T value)
          Adds a value to the front of the list.
 JImmutableList<T> insertLast(T value)
          Adds a value to the end of the list.
 boolean isEmpty()
           
 int size()
          Retrieve the number of values available in the container.
 
Methods inherited from interface org.javimmutable.collections.Cursorable
cursor
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

size

int size()
Description copied from interface: Indexed
Retrieve the number of values available in the container.

Specified by:
size in interface Indexed<T>
Returns:
number of values in the list

get

T get(int index)
Retrieves the value at the specified index (which must be within the bounds of the list).

Specified by:
get in interface Indexed<T>
Parameters:
index -
Returns:
Throws:
IndexOutOfBoundsException - if index is out of bounds

assign

@Nonnull
JImmutableList<T> assign(int index,
                                 @Nullable
                                 T value)
Replaces the value at the specified index (which must be within current bounds of the list) with the new value.

Parameters:
index -
value -
Returns:
Throws:
IndexOutOfBoundsException - if index is out of bounds

insert

@Nonnull
JImmutableList<T> insert(@Nullable
                                 T value)
Adds a value to the end of the list. May be invoked on an empty list.

Specified by:
insert in interface Insertable<T>
Parameters:
value -
Returns:

insert

@Nonnull
JImmutableList<T> insert(@Nonnull
                                 Iterable<? extends T> values)
Adds the values to the end of the list in the same order they appear in the Iterable. May be invoked on an empty list.

Parameters:
values -
Returns:

insertFirst

@Nonnull
JImmutableList<T> insertFirst(@Nullable
                                      T value)
Adds a value to the front of the list. May be invoked on an empty list. Synonym for insert()

Parameters:
value -
Returns:

insertLast

@Nonnull
JImmutableList<T> insertLast(@Nullable
                                     T value)
Adds a value to the end of the list. May be invoked on an empty list. Synonym for insert().

Parameters:
value -
Returns:

deleteFirst

@Nonnull
JImmutableList<T> deleteFirst()
Removes the first value from the list and reduces size by 1. size() must be greater than zero

Returns:
new PersistentList without last value
Throws:
IndexOutOfBoundsException - if list is already empty

deleteLast

@Nonnull
JImmutableList<T> deleteLast()
Removes the last value from the list and reduces size by 1. size() must be greater than zero

Returns:
new PersistentList without last value
Throws:
IndexOutOfBoundsException - if list is already empty

isEmpty

boolean isEmpty()
Returns:
true only if list contains no values

deleteAll

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

getList

@Nonnull
List<T> getList()
Returns an unmodifiable List implementation backed by this list.

Returns:


Copyright © 2014 Burton Computer Corporation. All rights reserved.