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
true
if this collection changed as a result of the call. (Returns false
if this
collection does not permit duplicates and already contains the specified element.)
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 ensuredtrue
if this collection changed as a result of the callIllegalArgumentException
- 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 collectiontrue
if this collection changed as a result of the callCollection.add(Object)
public void clear()
Collection
public boolean contains(Object element)
Collection
true
if this collection contains the specified element. More formally, returns
true
if and only if this collection contains at least one element e
such that
(o==null ? e==null : o.equals(e))
.element
- element whose presence in this collection is to be testedtrue
if this collection contains the specified elementpublic boolean isEmpty()
Collection
true
if this collection contains no elements.true
if this collection contains no elementspublic Iterator<T> iterator()
Collection
Iterator
over the elements in this collectionpublic boolean remove(Object element)
Collection
e
such that
(o==null ? e==null : o.equals(e))
, if this collection contains one
or more such elements. Returns true
if this collection contained the specified element
(or equivalently, if this collection changed as a result of the call).element
- element to be removed from this collection, if presenttrue
if an element was removed as a result of this callprotected void removeAllElementsOwnedBy(Feature feature)
AbstractKFList
Feature
.removeAllElementsOwnedBy
in class AbstractKFList<T>
feature
- the owner of the elements to be removedpublic int size()
Collection
Integer.MAX_VALUE
elements, returns Integer.MAX_VALUE
.protected void toArray(ArrayList<T> allList)
AbstractKFList
ArrayList
.toArray
in class AbstractKFList<T>
allList
- the list where all elements are added.