public class KFList2<T> extends AbstractKFList<T>
AbstractKFList
optimized for heap size.
All internal arrays are resized, and iterators are executed without extra object copy.KFList
Constructor and Description |
---|
KFList2() |
Modifier and Type | Method and Description |
---|---|
boolean |
add(T element)
Ensures that this collection contains the specified element (optional operation).
|
boolean |
addAll(Collection<? extends T> c)
Adds all of the elements in the specified collection to this collection (optional operation).
|
void |
clear()
Removes all of the elements from this collection (optional operation).
|
boolean |
contains(Object element)
Returns true if this collection contains the specified element.
|
boolean |
isEmpty()
Returns true if this collection contains no elements.
|
Iterator<T> |
iterator()
Returns an iterator over the elements in this collection.
|
boolean |
remove(Object element)
Removes a single instance of the specified element from this collection, if it is present
(optional operation).
|
protected void |
removeAllElementsOwnedBy(Feature feature)
Removed all elements owned by the given
Feature . |
int |
size()
Returns the number of elements in this collection.
|
protected void |
toArray(ArrayList<T> allList)
Add all the elements of the collection to the given
ArrayList . |
containsAll, removeAll, retainAll, stateChanged, toArray, toArray
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
equals, hashCode
public boolean add(T element)
Collection
Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.
If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false ). This preserves the invariant that a collection always contains the specified element after this call returns.
element
- element whose presence in this collection is to be ensuredIllegalArgumentException
- if this method is called by the Kernel and the element is owned by a Feature.public boolean addAll(Collection<? extends T> c)
Collection
addAll
in interface Collection<T>
addAll
in class AbstractKFList<T>
c
- collection containing elements to be added to this collectionCollection.add(Object)
public void clear()
Collection
public boolean contains(Object element)
Collection
element
- element whose presence in this collection is to be testedpublic boolean isEmpty()
Collection
public Iterator<T> iterator()
Collection
public boolean remove(Object element)
Collection
element
- element to be removed from this collection, if presentprotected void removeAllElementsOwnedBy(Feature feature)
AbstractKFList
Feature
.removeAllElementsOwnedBy
in class AbstractKFList<T>
feature
- the owner of the elements to be removedpublic int size()
Collection
protected void toArray(ArrayList<T> allList)
AbstractKFList
ArrayList
.toArray
in class AbstractKFList<T>
allList
- the list where all elements are added.