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

java.lang.Object
  extended by org.millscript.commons.util.list.AbstractIList<V>
      extended by org.millscript.commons.util.list.AbstractUList<V>
          extended by org.millscript.commons.util.list.AbstractEList<V>
              extended by org.millscript.commons.util.list.ELinkedList<V>
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, EList<V>, IList<V>, IMap<java.lang.Integer,V>, UList<V>, UMap<java.lang.Integer,V>

public class ELinkedList<V>
extends AbstractEList<V>
implements java.lang.Cloneable, java.io.Serializable

This class provides a mutable List implementation which is backed by singly linked list. We don't need the complexity of a doubly linked list as our iterators do not allow reverse iteration.

See Also:
Serialized Form

Nested Class Summary
static class ELinkedList.ELinkedListIterator<V>
          This class provides a map interator implementation which iterates over this values in the specified linked list.
static class ELinkedList.SharedLinkedListIterator<V>
          This class provides a map interator implementation which iterates over a shared poriton of the specified linked list.
static class ELinkedList.SharedLinkedListList<V>
          This class implements a linked list which is backed by a shared slice of another linked list.
 
Nested classes/interfaces inherited from class org.millscript.commons.util.list.AbstractIList
AbstractIList.ListMapletIterator<V>, AbstractIList.ListMapletList<V>
 
Constructor Summary
ELinkedList()
          Constructs a new empty mutable linked list.
ELinkedList(V[] objects)
          Constructs a new mutable linked list with the objects in the given array, in the same order.
ELinkedList(V[] objects, int start, int end)
          Constructs a new mutable linked list with the objects in the given array, in the same order, starting and ending at the specified indices.
 
Method Summary
 void addFirst(V value)
          Adds the specified value to the begining of this list.
 void addLast(V value)
          Adds the specified value to the end of this list.
 java.lang.Object clone()
           
 void deleteAll()
          Removes all the mappings from this list.
 void deleteFirst()
          Removes the first element from the list.
 void deleteLast()
          Removes the last element from the list.
 void deleteValue(V value)
          Removes all elements from this list which are equal to the specified value.
protected  void doDelete(int key, V value)
          Removes the value at the specified position(one based) in the list, but only if it matches the specified one.
protected  void doDeleteKey(int key)
          Removes the value at the specified index(one based), shifting any subsequent elements to an index one lower than before.
protected  V doGet(int pos)
          Returns the value at the specified position(one based) in the list.
protected  void doRemoveSlice(int first, int last)
          Removes the specified slice of elements in this list, starting at first(one based, inclusive) and continuing last(one based, inclusive).
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).
protected  void doUpdate(int key, V value)
          Updates the value at the specified index(one based) with that specified.
 int indexOf(V value)
          Returns the index(one based) of the first occurance of the specified object in this list.
 void insert(int pos, V value)
          Inserts the specified value at the given position(one based) 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.
 
Methods inherited from class org.millscript.commons.util.list.AbstractEList
append, delete, delete, delete, delete0, delete0, delete0, deleteAll, deleteKey, deleteKey, deleteKey0, deleteKey0, deleteSlice, deleteSlice0, insert, insert, insert0, insert0, insert0, prefix
 
Methods inherited from class org.millscript.commons.util.list.AbstractUList
update, update, update, update0, update0, update0, updateAll
 
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, toArray, toString, valueList
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.millscript.commons.util.UList
update, update, update, update0, update0, update0
 
Methods inherited from interface org.millscript.commons.util.IList
allButFirst, allButLast, allFirst, allLast, contains, contains, contains0, contains0, contains0, containsKey, containsKey, containsKey0, containsKey0, containsSlice, containsSlice0, first, get, get, get0, get0, getDefault, indexOf0, last, setDefault, slice, slice0, toArray, toArray
 
Methods inherited from interface org.millscript.commons.util.IMap
contains, containsAll, containsValue, equals, hashCode, isEmtpy, keyList, mapletList, setDefault, valueList
 
Methods inherited from interface org.millscript.commons.util.UMap
updateAll
 
Methods inherited from interface org.millscript.commons.util.IMap
contains, containsAll, containsValue, equals, hashCode, isEmtpy, keyList, mapletList, setDefault, valueList
 

Constructor Detail

ELinkedList

public ELinkedList()
Constructs a new empty mutable linked list.


ELinkedList

public ELinkedList(V[] objects)
Constructs a new mutable linked list with the objects in the given array, in the same order.

Parameters:
objects - the backing object array with objects to populate the list with

ELinkedList

public ELinkedList(V[] objects,
                   int start,
                   int end)
Constructs a new mutable linked list with the objects in the given array, in the same order, starting and ending at the specified indices.

Parameters:
objects - the backing object array with objects to populate the list with
start - the index of the first element in the slice
end - the index of the last element in the slice. If end < start, the new list will be empty
Method Detail

addFirst

public void addFirst(V value)
Description copied from interface: EList
Adds the specified value to the begining of this list.

Specified by:
addFirst in interface EList<V>
Parameters:
value - the value to add to the begining of the list
See Also:
EList.addFirst(java.lang.Object)

addLast

public void addLast(V value)
Description copied from interface: EList
Adds the specified value to the end of this list.

Specified by:
addLast in interface EList<V>
Parameters:
value - the value to add to the end of the list
See Also:
EList.addLast(java.lang.Object)

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

deleteAll

public void deleteAll()
Description copied from interface: EList
Removes all the mappings from this list.

Specified by:
deleteAll in interface EList<V>
See Also:
EList.deleteAll()

deleteFirst

public void deleteFirst()
Description copied from interface: EList
Removes the first element from the list.

Specified by:
deleteFirst in interface EList<V>
See Also:
EList.deleteFirst()

deleteLast

public void deleteLast()
Description copied from interface: EList
Removes the last element from the list.

Specified by:
deleteLast in interface EList<V>
See Also:
EList.deleteLast()

deleteValue

public void deleteValue(V value)
Description copied from interface: EList
Removes all elements from this list which are equal to the specified value.

Specified by:
deleteValue in interface EList<V>
Parameters:
value - the value to remove from this list
See Also:
EList.deleteValue(java.lang.Object)

doDelete

protected void doDelete(int key,
                        V value)
Description copied from class: AbstractEList
Removes the value at the specified position(one based) in the list, but only if it matches the specified one. If the element is sucessfully deleted, any subsequent elements are shifted to an index one lower than before. This method is called by the generic AbstractEList.doDelete(int, Object) method after the index has been validated. Hence this method should generally not need to perform any further validation.

Specified by:
doDelete in class AbstractEList<V>
value - the value which must match that stored at the specified position(one based) in the list
See Also:
AbstractEList.doDelete(int, java.lang.Object)

doDeleteKey

protected void doDeleteKey(int key)
Description copied from class: AbstractEList
Removes the value at the specified index(one based), shifting any subsequent elements to an index one lower than before. This method is called by the generic AbstractEList.doDeleteKey(int) method after the index has been validated. Hence this method should generally not need to perform any further validation.

Specified by:
doDeleteKey in class AbstractEList<V>
Parameters:
key - the index(one based) of the value to remove
See Also:
AbstractEList.doDeleteKey(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)

doRemoveSlice

protected void doRemoveSlice(int first,
                             int last)
Description copied from class: AbstractEList
Removes the specified slice of elements in this list, starting at first(one based, inclusive) and continuing last(one based, inclusive). This method is called by the generic AbstractEList.deleteSlice(int, int) method after the index has been validated. Hence this method should generally not need to perform any further validation.

Specified by:
doRemoveSlice in class AbstractEList<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
See Also:
AbstractEList.doRemoveSlice(int, 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)

doUpdate

protected void doUpdate(int key,
                        V value)
Description copied from class: AbstractUList
Updates the value at the specified index(one based) with that specified. This method is called by the generic AbstractUList.update(int, Object) method after the index has been validated. Hence this method should generally not need to perform any further validation.

Specified by:
doUpdate in class AbstractUList<V>
Parameters:
key - the index(one based) of the value to update
value - the new value for the specified index
See Also:
AbstractUList.doUpdate(int, java.lang.Object)

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)

insert

public void insert(int pos,
                   V value)
Description copied from interface: EList
Inserts the specified value at the given position(one based) in this list. Any subsequent values will be shifted to an index one higher than they were before this operation.

Specified by:
insert in interface EList<V>
Parameters:
pos - the position(one based) at which to insert the value
value - the value to insert
See Also:
EList.insert(int, 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()


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