org.javimmutable.collections
Interface JImmutableRandomAccessList<T>

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

@Immutable
public interface JImmutableRandomAccessList<T>
extends JImmutableList<T>

Extension of PersistentList that allows insertion and deletion at arbitrary indexes within the list.


Nested Class Summary
static interface JImmutableRandomAccessList.Builder<T>
           
 
Method Summary
 JImmutableRandomAccessList<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.
 JImmutableRandomAccessList<T> delete(int index)
          Delete value at index (which must be within the current bounds of the list).
 JImmutableRandomAccessList<T> deleteAll()
           
 JImmutableRandomAccessList<T> deleteFirst()
          Removes the first value from the list and reduces size by 1.
 JImmutableRandomAccessList<T> deleteLast()
          Removes the last value from the list and reduces size by 1.
 JImmutableRandomAccessList<T> insert(int index, T value)
          Insert value at index (which must be within 0 to size).
 JImmutableRandomAccessList<T> insert(T value)
          Adds a value to the end of the list.
 JImmutableRandomAccessList<T> insertFirst(T value)
          Adds a value to the front of the list.
 JImmutableRandomAccessList<T> insertLast(T value)
          Adds a value to the end of the list.
 
Methods inherited from interface org.javimmutable.collections.JImmutableList
get, getList, insert, isEmpty, size
 
Methods inherited from interface org.javimmutable.collections.Cursorable
cursor
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

assign

@Nonnull
JImmutableRandomAccessList<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.

Specified by:
assign in interface JImmutableList<T>
Parameters:
index -
value -
Returns:
Throws:
IndexOutOfBoundsException - if index is out of bounds

insert

@Nonnull
JImmutableRandomAccessList<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>
Specified by:
insert in interface JImmutableList<T>
Parameters:
value -
Returns:

insert

@Nonnull
JImmutableRandomAccessList<T> insert(int index,
                                             @Nullable
                                             T value)
Insert value at index (which must be within 0 to size). Shifts all values at and after index one position to the right and adds 1 to size of the list.

Parameters:
index -
value -
Returns:

insertFirst

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

Specified by:
insertFirst in interface JImmutableList<T>
Parameters:
value -
Returns:

insertLast

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

Specified by:
insertLast in interface JImmutableList<T>
Parameters:
value -
Returns:

deleteFirst

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

Specified by:
deleteFirst in interface JImmutableList<T>
Returns:
new PersistentList without last value
Throws:
IndexOutOfBoundsException - if list is already empty

deleteLast

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

Specified by:
deleteLast in interface JImmutableList<T>
Returns:
new PersistentList without last value
Throws:
IndexOutOfBoundsException - if list is already empty

delete

@Nonnull
JImmutableRandomAccessList<T> delete(int index)
Delete value at index (which must be within the current bounds of the list). Shifts all values at and after index one position to the left and subtracts 1 from size of the list.

Parameters:
index -
Returns:

deleteAll

@Nonnull
JImmutableRandomAccessList<T> deleteAll()
Specified by:
deleteAll in interface JImmutableList<T>
Returns:
an equivalent collection with no values


Copyright © 2014 Burton Computer Corporation. All rights reserved.