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

java.lang.Object
  extended by org.millscript.commons.util.list.AbstractIList<V>
All Implemented Interfaces:
IList<V>, IMap<java.lang.Integer,V>
Direct Known Subclasses:
AbstractEReferenceHashMap.HashMapKeysList, AbstractEReferenceHashMap.HashMapMapletList, AbstractEReferenceHashMap.HashMapValuesList, AbstractIList.ListMapletList, AbstractITreeMap.ITreeMapNodeList, AbstractUList, EBinaryTreeMap.NodeXList, EHashMap.HashMapKeysList, EHashMap.HashMapMapletList, EHashMap.HashMapValuesList, ELinkedHashMap.LinkedHashMapKeysList, ELinkedHashMap.LinkedHashMapMapletList, ELinkedHashMap.LinkedHashMapValuesList, ELinkedList.SharedLinkedListList, IArrayList, IArrayMap.ImmutableSharedMapletList, IArrayMap.ImmutableXList, IArraySet.ArraySetMapletList, IArraySet.SharedArraySetMapletList, IDynamicList, IDynamicList.ISharedDynamicList, IEmptyList, IHashMap.HashMapKeysList, IHashMap.HashMapMapletList, IHashMap.HashMapValuesList, IIntegerList, IJavaUtilList, IJavaUtilList.ImmutableSharedJavaUtilList, ILinkedHashMap.LinkedHashMapKeysList, ILinkedHashMap.LinkedHashMapMapletList, ILinkedHashMap.LinkedHashMapValuesList, ILinkedList, ILinkedList.ISharedLinkedList, IMapletArrayMap.MapletArrayKeysList, IMapletArrayMap.MapletArrayValuesList, IMapletList, ISharedArrayList, ISingletonList, IStringList, ITwoArrayMap.SharedTwoArrayMapletList, ITwoArrayMap.TwoArrayMapletList, IVarLengthList

public abstract class AbstractIList<V>
extends java.lang.Object
implements IList<V>


Nested Class Summary
static class AbstractIList.ListMapletIterator<V>
          This class implements an iterator over the maplets in another map.
static class AbstractIList.ListMapletList<V>
           
 
Constructor Summary
protected AbstractIList()
          Constructs a new abstract immutable list with a ListDefault as it's default.
protected AbstractIList(IListDefault<V> def)
          Constructs a new abstract immutable list with the specified default action.
 
Method Summary
 IList<V> allButFirst(int num, boolean share)
          Returns a list containing all but the first num elements held in this list.
 IList<V> allButLast(int num, boolean share)
          Returns a list containing all but the last num elements held in this list.
 IList<V> allFirst(int num, boolean share)
          Returns a list containing the first num elements held in this list.
 IList<V> allLast(int num, boolean share)
          Returns a list containing the last num elements held in this list.
 boolean contains(java.lang.Integer key, V value)
          Returns true if this list contains the specified value at the specified position(one based) in the list.
 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 contains(Maplet<? extends java.lang.Integer,? extends V> entry)
          Returns true if this map contains the specified maplet.
 boolean contains0(java.lang.Integer key, V value)
          Returns true if this list contains the specified value at the specified position(zero based) in the list.
 boolean contains0(int key, V value)
          Returns true if this list contains the specified value at the specified position(zero based) in the list.
 boolean contains0(Maplet<? extends java.lang.Integer,? extends V> entry)
          Returns true if this list contains the specified maplet.
 boolean containsAll(IMap<? extends java.lang.Integer,? extends V> map)
          Returns true if this map contains all the mappings in the specified map.
 boolean containsKey(int pos)
          Returns true if the specified position(one based) is valid in this list.
 boolean containsKey(java.lang.Integer pos)
          Returns true if the specified position(one based) is valid in this list.
 boolean containsKey0(int pos)
          Returns true if the specified position(zero based) is valid in this list.
 boolean containsKey0(java.lang.Integer pos)
          Returns true if the specified position(zero 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.
 boolean containsSlice0(int first, int last)
          Returns true if the specified slice is within the bounds of the list.
 boolean containsValue(V value)
          Returns true if this map contains an entry with the specified value.
 org.millscript.commons.alert.Alert decorate(org.millscript.commons.alert.Alert alert)
           
protected abstract  V doGet(int pos)
          Returns the value at the specified position(one based) in the list.
protected abstract  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).
 boolean equals(java.lang.Object obj)
          Compares this map with the specified object for equality.
 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.
 V get(java.lang.Integer pos)
          Returns the element at the specified position(one based) in this list.
 V get0(int pos)
          Returns the element at the specified position(zero based) in this list.
 V get0(java.lang.Integer pos)
          Returns the element at the specified position(zero based) in this list.
 IListDefault<V> getDefault()
          Returns the default used by the IMap.get(Object) method when there is no mapping for a given key.
 int hashCode()
          Returns the integer hash code for this map.
 int indexOf0(V value)
          Returns the index(zero based) of the first occurance of the specified object in this list.
 boolean isEmtpy()
          Returns true if this map has no mappings.
 IList<java.lang.Integer> keyList(boolean share)
          Returns a List of the keys in this map.
 V last()
          Returns the last item from this list.
 IList<Maplet<java.lang.Integer,V>> mapletList(boolean share)
          Returns a List of the maplets in this map.
 void setDefault(IListDefault<V> def)
          Sets the default for this list.
 void setDefault(IMapDefault<java.lang.Integer,V> def)
          Sets the default for this map.
protected  IList<Maplet<java.lang.Integer,V>> sharedMapletList()
           
protected  IList<V> sharedValueList()
           
 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).
 IList<V> slice0(int first, int last, boolean share)
          Returns a list containing a slice of the elements in this list, starting at first(zero based, inclusive) and continuing last(zero based, inclusive).
 java.lang.Object[] toArray()
          Returns an array containing all the elements of this list.
 V[] toArray(V[] target)
          Attempts to store the contents of this list inside the specified array.
 java.lang.String toString()
           
 IList<V> valueList(boolean share)
          Returns a List of the values in this map.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.millscript.commons.util.IList
indexOf, iterator
 
Methods inherited from interface org.millscript.commons.util.IMap
size
 

Constructor Detail

AbstractIList

protected AbstractIList()
Constructs a new abstract immutable list with a ListDefault as it's default.


AbstractIList

protected AbstractIList(IListDefault<V> def)
Constructs a new abstract immutable list with the specified default action.

Parameters:
def - the default action for this map
Method Detail

allButFirst

public IList<V> allButFirst(int num,
                            boolean share)
Description copied from interface: IList
Returns a list containing all but the first num elements held in this list.

Specified by:
allButFirst in interface IList<V>
Parameters:
num - the number of elements to skip from the begining of this list
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 all but the first num elements held in this list
See Also:
IList.allButFirst(int, boolean)

allButLast

public IList<V> allButLast(int num,
                           boolean share)
Description copied from interface: IList
Returns a list containing all but the last num elements held in this list.

Specified by:
allButLast in interface IList<V>
Parameters:
num - the number of elements to skip from the end of this list
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 all but the last num elements held in this list
See Also:
IList.allButLast(int, boolean)

allFirst

public IList<V> allFirst(int num,
                         boolean share)
Description copied from interface: IList
Returns a list containing the first num elements held in this list.

Specified by:
allFirst in interface IList<V>
Parameters:
num - the number of elements to slice from the start of this list
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 first num elements held in this list
See Also:
IList.allFirst(int, boolean)

allLast

public IList<V> allLast(int num,
                        boolean share)
Description copied from interface: IList
Returns a list containing the last num elements held in this list.

Specified by:
allLast in interface IList<V>
Parameters:
num - the number of elements to slice from the end of this list
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 last num elements held in this list
See Also:
IList.allLast(int, boolean)

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

contains

public boolean contains(java.lang.Integer 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>
Specified by:
contains in interface IMap<java.lang.Integer,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(java.lang.Integer, java.lang.Object)

contains

public boolean contains(Maplet<? extends java.lang.Integer,? extends V> entry)
Description copied from interface: IMap
Returns true if this map contains the specified maplet.

Specified by:
contains in interface IMap<java.lang.Integer,V>
Parameters:
entry - the maplet whose presence to test
Returns:
true if this map contains the specified maplet
See Also:
IMap.contains(org.millscript.commons.util.Maplet)

contains0

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

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

contains0

public boolean contains0(java.lang.Integer key,
                         V value)
Description copied from interface: IList
Returns true if this list contains the specified value at the specified position(zero based) in the list.

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

contains0

public boolean contains0(Maplet<? extends java.lang.Integer,? extends V> entry)
Description copied from interface: IList
Returns true if this list contains the specified maplet. The maplet key is the position(zero based) in the list and the maplet value is the value at the specified position(zero based).

Specified by:
contains0 in interface IList<V>
Parameters:
entry - the maplet whose presence to test
Returns:
true if this list contains the specified maplet
See Also:
IList.contains0(org.millscript.commons.util.Maplet)

containsAll

public boolean containsAll(IMap<? extends java.lang.Integer,? extends V> map)
Description copied from interface: IMap
Returns true if this map contains all the mappings in the specified map.

Specified by:
containsAll in interface IMap<java.lang.Integer,V>
Returns:
true if this map contains the specified maplet
See Also:
IMap.containsAll(org.millscript.commons.util.IMap)

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>
Returns:
true if the specified position(one based) is valid in this list
See Also:
IList.containsKey(int)

containsKey

public boolean containsKey(java.lang.Integer 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>
Specified by:
containsKey in interface IMap<java.lang.Integer,V>
Parameters:
pos - the key whose presence to test
Returns:
true if the specified position(one based) is valid in this list
See Also:
IList.containsKey(java.lang.Integer)

containsKey0

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

Specified by:
containsKey0 in interface IList<V>
Returns:
true if the specified position(zero based) is valid in this list
See Also:
IList.containsKey0(int)

containsKey0

public boolean containsKey0(java.lang.Integer pos)
Description copied from interface: IList
Returns true if the specified position(zero based) is valid in this list. The position would be valid if it is suchthat 0 <= pos < size().

Specified by:
containsKey0 in interface IList<V>
Returns:
true if the specified position(zero based) is valid in this list
See Also:
IList.containsKey0(java.lang.Integer)

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

containsSlice0

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

Specified by:
containsSlice0 in interface IList<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.containsSlice0(int, int)

containsValue

public boolean containsValue(V value)
Description copied from interface: IMap
Returns true if this map contains an entry with the specified value.

Specified by:
containsValue in interface IMap<java.lang.Integer,V>
Parameters:
value - the value whose presence to test
Returns:
true if this map contains a mapping with the specified value
See Also:
IMap.containsValue(java.lang.Object)

decorate

public org.millscript.commons.alert.Alert decorate(org.millscript.commons.alert.Alert alert)
See Also:
AlertDecorator.decorate(org.millscript.commons.alert.Alert)

doGet

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

Parameters:
pos - the index(one based) of the value to return
Returns:
the value at the specified position(one based)

doSlice

protected abstract 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). 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.

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

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: IMap
Compares this map with the specified object for equality. The two maps are considered equal if they both contain the same number of mappings, mapping the same key to the same value.

Specified by:
equals in interface IMap<java.lang.Integer,V>
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with this map for equality
Returns:
true if this map and the specified object are equal and false otherwise
See Also:
IMap.equals(Object)

first

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

Specified by:
first in interface IList<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>
Parameters:
pos - index of the element to return(one based)
Returns:
the element at the specified position
See Also:
IList.get(int)

get

public V get(java.lang.Integer 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>
Specified by:
get in interface IMap<java.lang.Integer,V>
Parameters:
pos - index of the element to return(one based)
Returns:
the element at the specified position
See Also:
IList.get(java.lang.Integer)

get0

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

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

get0

public V get0(java.lang.Integer pos)
Description copied from interface: IList
Returns the element at the specified position(zero based) in this list.

Specified by:
get0 in interface IList<V>
Parameters:
pos - index of the element to return(zero based)
Returns:
the element at the specified position
See Also:
IList.get0(java.lang.Integer)

getDefault

public IListDefault<V> getDefault()
Description copied from interface: IMap
Returns the default used by the IMap.get(Object) method when there is no mapping for a given key.

Specified by:
getDefault in interface IList<V>
Specified by:
getDefault in interface IMap<java.lang.Integer,V>
Returns:
the default to be used when a key has no mapping.
See Also:
IMap.getDefault()

hashCode

public int hashCode()
Description copied from interface: IMap
Returns the integer hash code for this map. The hash code is calculated as the simple sum of hash codes for each mapping in this map. For any two maps that are equal, they should have the same hash code.

We require a simple sum of Maplet hash codes as different IMap implementations may have different iteration orders. As a result the hash code method must return the same hash code regardless of iteration order.

Specified by:
hashCode in interface IMap<java.lang.Integer,V>
Overrides:
hashCode in class java.lang.Object
Returns:
the integer hash code for this map
See Also:
IMap.hashCode()

indexOf0

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

Specified by:
indexOf0 in interface IList<V>
Parameters:
value - the value to find
Returns:
the index(zero based) of the first occurance of the specified object in this list or -1 if no such element exists
See Also:
IList.indexOf0(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>
Returns:
true if this map contains no mappings
See Also:
IMap.isEmtpy()

keyList

public IList<java.lang.Integer> keyList(boolean share)
Description copied from interface: IMap
Returns a List of the keys in this map. The ordering of the List will be dependant on the implementation and should match the order of iteration.

Specified by:
keyList 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:
a List of the keys in this map
See Also:
IMap.keyList(boolean)

last

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

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

mapletList

public IList<Maplet<java.lang.Integer,V>> mapletList(boolean share)
Description copied from interface: IMap
Returns a List of the maplets in this map. The ordering of the List will be dependant on the implementation and should match the order of iteration.

Specified by:
mapletList 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:
a List of the keys in this map
See Also:
IMap.mapletList(boolean)

setDefault

public void setDefault(IListDefault<V> def)
Sets the default for this list.

Specified by:
setDefault in interface IList<V>
Parameters:
def - the new default
See Also:
IMap.setDefault(org.millscript.commons.util.IMapDefault)

setDefault

public void setDefault(IMapDefault<java.lang.Integer,V> def)
Description copied from interface: IMap
Sets the default for this map.

Specified by:
setDefault in interface IMap<java.lang.Integer,V>
Parameters:
def - the new default
See Also:
IMap.setDefault(org.millscript.commons.util.IMapDefault)

sharedMapletList

protected IList<Maplet<java.lang.Integer,V>> sharedMapletList()

sharedValueList

protected IList<V> sharedValueList()

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

slice0

public IList<V> slice0(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(zero based, inclusive) and continuing last(zero based, inclusive).

Specified by:
slice0 in interface IList<V>
Parameters:
first - the index(zero based) of the first element in the slice
last - the index(zero 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.slice0(int, int, boolean)

toArray

public java.lang.Object[] toArray()
Description copied from interface: IList
Returns an array containing all the elements of this list. The elements in this array will be in the same order as they would have been obtained from this lists iterator.

Specified by:
toArray in interface IList<V>
Returns:
an array of all the values in this list
See Also:
IList.toArray()

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>
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[])

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

valueList

public IList<V> valueList(boolean share)
Description copied from interface: IMap
Returns a List of the values in this map. The ordering of the List will be dependant on the implementation and should match the order of iteration.

Specified by:
valueList 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:
a List of the keys in this map
See Also:
IMap.valueList(boolean)


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