org.millscript.commons.util.list
Class IArrayList<V>

java.lang.Object
  extended by org.millscript.commons.util.list.AbstractIList<V>
      extended by org.millscript.commons.util.list.IArrayList<V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, IList<V>, IMap<java.lang.Integer,V>

public class IArrayList<V>
extends AbstractIList<V>
implements java.lang.Cloneable, java.io.Serializable

This class provides an immutable List implementation which is backed by an Object array.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.millscript.commons.util.list.AbstractIList
AbstractIList.ListMapletIterator<V>, AbstractIList.ListMapletList<V>
 
Constructor Summary
IArrayList()
          Constructs a new empty immutable array list.
IArrayList(V[] objects, boolean share)
          Constructs a new immutable array list with the specified backing object array.
IArrayList(V[] objects, int start, int end)
          Constructs a new immutable array list with a copy of the specified backing object array, starting and ending at the specified indices.
 
Method Summary
 java.lang.Object clone()
           
protected  V doGet(int pos)
          Returns the value at the specified position(one based) in the list.
protected  IList<V> doSlice(int first, int last, boolean share)
          Returns a list containing a slice of the elements in this list, starting at first(one based, inclusive) and continuing last(one based, inclusive).
 int indexOf(V value)
          Returns the index(one based) of the first occurance of the specified object in this list.
 ListIterator<V> iterator(boolean share)
          Returns an iterator over the values in this list and their respective position.
 int size()
          Returns the number of mappings defined in this map.
 V[] toArray(V[] target)
          Attempts to store the contents of this list inside the specified array.
 
Methods inherited from class org.millscript.commons.util.list.AbstractIList
allButFirst, allButLast, allFirst, allLast, contains, contains, contains, contains0, contains0, contains0, containsAll, containsKey, containsKey, containsKey0, containsKey0, containsSlice, containsSlice0, containsValue, decorate, equals, first, get, get, get0, get0, getDefault, hashCode, indexOf0, isEmtpy, keyList, last, mapletList, setDefault, setDefault, sharedMapletList, sharedValueList, slice, slice0, toArray, toString, valueList
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IArrayList

public IArrayList()
Constructs a new empty immutable array list.


IArrayList

public IArrayList(V[] objects,
                  boolean share)
Constructs a new immutable array list with the specified backing object array.

Parameters:
objects - the backing object array to copy
share - if true the specified object array will be shared otherwise the array will be copied.

IArrayList

public IArrayList(V[] objects,
                  int start,
                  int end)
Constructs a new immutable array list with a copy of the specified backing object array, starting and ending at the specified indices.

Parameters:
objects - the backing object array to copy
start - the index(one based, inclusive) of the first element in the slice
end - the index(one based, inclusive) of the last element in the slice. If end < start, the new list will be empty
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

doGet

protected V doGet(int pos)
Description copied from class: AbstractIList
Returns the value at the specified position(one based) in the list. This method is called by the generic AbstractIList.get(int) method after the index has been validated. Hence this method should generally not need to perform any further validation.

Specified by:
doGet in class AbstractIList<V>
Parameters:
pos - the index(one based) of the value to return
Returns:
the value at the specified position(one based)
See Also:
AbstractIList.doGet(int)

doSlice

protected IList<V> doSlice(int first,
                           int last,
                           boolean share)
Description copied from class: AbstractIList
Returns a list containing a slice of the elements in this list, starting at first(one based, inclusive) and continuing last(one based, inclusive). This method is called by the generic #slice(int, int) method after the indices have been validated. Hence, this method assumes that the specified indices are within the bounds of the list and that the first index is less than or equal to the last index. The case where the first index is greater than the last is handled elsewhere.

Specified by:
doSlice in class AbstractIList<V>
Parameters:
first - the index(one based) of the first element in the slice
last - the index(one based) of the last element in the slice
share - if true the specified object array will be shared otherwise the array will be copied.
Returns:
a list containing the specified slice of this list
See Also:
AbstractIList.doSlice(int, int, boolean)

indexOf

public int indexOf(V value)
Description copied from interface: IList
Returns the index(one based) of the first occurance of the specified object in this list.

Specified by:
indexOf in interface IList<V>
Parameters:
value - the value to find
Returns:
the index(one based) of the first occurance of the specified object in this list or 0 if no such element exists
See Also:
IList.indexOf(java.lang.Object)

iterator

public ListIterator<V> iterator(boolean share)
Description copied from interface: IList
Returns an iterator over the values in this list and their respective position. The order of iteration is implementation dependant and should follow any ordering the list implementation provides.

Specified by:
iterator in interface IList<V>
Specified by:
iterator in interface IMap<java.lang.Integer,V>
Parameters:
share - if true this instances backing store should be shared with the returned list, otherwise any backing store will be copied.
Returns:
an iterator over this maps mappings
See Also:
IMap.iterator(boolean)

size

public int size()
Description copied from interface: IMap
Returns the number of mappings defined in this map.

Specified by:
size in interface IMap<java.lang.Integer,V>
Returns:
the number of mappings in this map
See Also:
IMap.size()

toArray

public V[] toArray(V[] target)
Description copied from interface: IList
Attempts to store the contents of this list inside the specified array. If the array is not large enough to accommodate this list a new array of the same runtime type will be allocated and filled with the contents of this list. The returned array will have the runtime type of the supplied array.

Specified by:
toArray in interface IList<V>
Overrides:
toArray in class AbstractIList<V>
Parameters:
target - the array to fill with the elements in this list
Returns:
an array of all the values in this list, with the same runtime type as the supplied array
See Also:
org.millscript.commons.util.IList#toArray(null[])


Copyright © 2005-2007 Open World Ltd. All Rights Reserved.