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

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

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

This class implements an immutable dynamic list whose values are calculated on demand.

See Also:
Serialized Form

Nested Class Summary
static class IDynamicList.DynamicListIterator<V>
          This class implements a list iterator which is backed by a dynamic linked list.
static class IDynamicList.ISharedDynamicList<V>
          This class implements a list which is backed by a shared slice of a dynamic linked list.
static class IDynamicList.ListEntry<V>
          This class represents an entry in a dynamic list.
static class IDynamicList.SharedDynamicListIterator<V>
          This class implements a iterator which is backed by a shared slice of a dynamic linked list, but has a fixed number of values rather than all of them.
 
Nested classes/interfaces inherited from class org.millscript.commons.util.list.AbstractIList
AbstractIList.ListMapletIterator<V>, AbstractIList.ListMapletList<V>
 
Constructor Summary
IDynamicList(IDynamicList.ListEntry<V> first)
          Constructs a new
 
Method Summary
 java.lang.Object clone()
           
 boolean contains(int key, V value)
          Returns true if this list contains the specified value at the specified position(one based) in the list.
 boolean containsKey(int pos)
          Returns true if the specified position(one based) is valid in this list.
 boolean containsSlice(int first, int last)
          Returns true if the specified slice is within the bounds of the list.
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).
 V first()
          Returns the first item from this list.
 V get(int pos)
          Returns the element at the specified position(one based) in this list.
 IDynamicList.ListEntry<V> getEntry(int pos)
          Returns the list entry for the specified index(one based).
 int indexOf(V value)
          Returns the index(one based) of the first occurance of the specified object in this list.
 boolean isEmtpy()
          Returns true if this map has no mappings.
 ListIterator<V> iterator(boolean share)
          Returns an iterator over the values in this list and their respective position.
 V last()
          Returns the last item from this list.
 int size()
          Returns the number of mappings defined in this map.
 IList<V> slice(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).
 
Methods inherited from class org.millscript.commons.util.list.AbstractIList
allButFirst, allButLast, allFirst, allLast, contains, contains, contains0, contains0, contains0, containsAll, containsKey, containsKey0, containsKey0, containsSlice0, containsValue, decorate, equals, get, get0, get0, getDefault, hashCode, indexOf0, keyList, mapletList, setDefault, setDefault, sharedMapletList, sharedValueList, slice0, toArray, toArray, toString, valueList
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IDynamicList

public IDynamicList(IDynamicList.ListEntry<V> first)
Constructs a new

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()

contains

public boolean contains(int key,
                        V value)
Description copied from interface: IList
Returns true if this list contains the specified value at the specified position(one based) in the list.

Specified by:
contains in interface IList<V>
Overrides:
contains in class AbstractIList<V>
Parameters:
key - the index(one based) of the object whose presence to test
value - the value which must match that stored at the specified position(one based) in the list
Returns:
true if this list contains the specified value at the specified position(one based)
See Also:
IList.contains(int, java.lang.Object)

containsKey

public boolean containsKey(int pos)
Description copied from interface: IList
Returns true if the specified position(one based) is valid in this list. The position would be valid if it is suchthat 1 <= pos <= size().

Specified by:
containsKey in interface IList<V>
Overrides:
containsKey in class AbstractIList<V>
Returns:
true if the specified position(one based) is valid in this list
See Also:
IList.containsKey(int)

containsSlice

public boolean containsSlice(int first,
                             int last)
Description copied from interface: IList
Returns true if the specified slice is within the bounds of the list.

Specified by:
containsSlice in interface IList<V>
Overrides:
containsSlice 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
Returns:
true if the specified slice indicies are within the bounds of this list and false otherwise
See Also:
IList.containsSlice(int, int)

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)

first

public V first()
Description copied from interface: IList
Returns the first item from this list.

Specified by:
first in interface IList<V>
Overrides:
first in class AbstractIList<V>
Returns:
the first item in this list
See Also:
IList.first()

get

public V get(int pos)
Description copied from interface: IList
Returns the element at the specified position(one based) in this list.

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

getEntry

public IDynamicList.ListEntry<V> getEntry(int pos)
Returns the list entry for the specified index(one based).

Parameters:
pos - the index(one based) of the required list entry
Returns:
the ListEntry for the specified index

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)

isEmtpy

public boolean isEmtpy()
Description copied from interface: IMap
Returns true if this map has no mappings.

Specified by:
isEmtpy in interface IMap<java.lang.Integer,V>
Overrides:
isEmtpy in class AbstractIList<V>
Returns:
true if this map contains no mappings
See Also:
IMap.isEmtpy()

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)

last

public V last()
Description copied from interface: IList
Returns the last item from this list.

Specified by:
last in interface IList<V>
Overrides:
last in class AbstractIList<V>
Returns:
the last item in this list
See Also:
IList.last()

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()

slice

public IList<V> slice(int first,
                      int last,
                      boolean share)
Description copied from interface: IList
Returns a list containing a slice of the elements in this list, starting at first(one based, inclusive) and continuing last(one based, inclusive).

Specified by:
slice in interface IList<V>
Overrides:
slice 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 this instances backing store should be shared with the returned list, otherwise any backing store will be copied.
Returns:
a list containing the specified slice of this list
See Also:
IList.slice(int, int, boolean)


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