Package com.microej.kf.util
Class KFList2<T>
- java.lang.Object
-
- com.microej.kf.util.AbstractKFList<T>
-
- com.microej.kf.util.KFList2<T>
-
- All Implemented Interfaces:
FeatureStateListener,Iterable<T>,Collection<T>
public class KFList2<T> extends AbstractKFList<T>
Implementation of aAbstractKFListoptimized for heap size. All internal arrays are resized, and iterators are executed without extra object copy.- See Also:
KFList
-
-
Constructor Summary
Constructors Constructor Description KFList2()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(T element)Ensures that this collection contains the specified element (optional operation).booleanaddAll(Collection<? extends T> c)Adds all of the elements in the specified collection to this collection (optional operation).voidclear()Removes all of the elements from this collection (optional operation).booleancontains(Object element)Returnstrueif this collection contains the specified element.booleanisEmpty()Returnstrueif this collection contains no elements.Iterator<T>iterator()Returns an iterator over the elements in this collection.booleanremove(Object element)Removes a single instance of the specified element from this collection, if it is present (optional operation).protected voidremoveAllElementsOwnedBy(Feature feature)Removed all elements owned by the givenFeature.intsize()Returns the number of elements in this collection.protected voidtoArray(ArrayList<T> allList)Add all the elements of the collection to the givenArrayList.-
Methods inherited from class com.microej.kf.util.AbstractKFList
containsAll, removeAll, retainAll, stateChanged, toArray, toArray
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode
-
-
-
-
Method Detail
-
contains
public boolean contains(Object element)
Description copied from interface:CollectionReturnstrueif this collection contains the specified element. More formally, returnstrueif and only if this collection contains at least one elementesuch that(o==null ? e==null : o.equals(e)).- Parameters:
element- element whose presence in this collection is to be tested- Returns:
trueif this collection contains the specified element
-
add
public boolean add(T element)
Description copied from interface:CollectionEnsures that this collection contains the specified element (optional operation). Returnstrueif this collection changed as a result of the call. (Returnsfalseif 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
nullelements, 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.- Parameters:
element- element whose presence in this collection is to be ensured- Returns:
trueif this collection changed as a result of the call- Throws:
IllegalArgumentException- if this method is called by the Kernel and the element is owned by a Feature.
-
remove
public boolean remove(Object element)
Description copied from interface:CollectionRemoves a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an elementesuch that(o==null ? e==null : o.equals(e)), if this collection contains one or more such elements. Returnstrueif this collection contained the specified element (or equivalently, if this collection changed as a result of the call).- Parameters:
element- element to be removed from this collection, if present- Returns:
trueif an element was removed as a result of this call
-
iterator
public Iterator<T> iterator()
Description copied from interface:CollectionReturns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).- Returns:
- an
Iteratorover the elements in this collection
-
addAll
public boolean addAll(Collection<? extends T> c)
Description copied from interface:CollectionAdds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)- Specified by:
addAllin interfaceCollection<T>- Overrides:
addAllin classAbstractKFList<T>- Parameters:
c- collection containing elements to be added to this collection- Returns:
trueif this collection changed as a result of the call- See Also:
Collection.add(Object)
-
clear
public void clear()
Description copied from interface:CollectionRemoves all of the elements from this collection (optional operation). The collection will be empty after this method returns.
-
isEmpty
public boolean isEmpty()
Description copied from interface:CollectionReturnstrueif this collection contains no elements.- Returns:
trueif this collection contains no elements
-
size
public int size()
Description copied from interface:CollectionReturns the number of elements in this collection. If this collection contains more thanInteger.MAX_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of elements in this collection
-
toArray
protected void toArray(ArrayList<T> allList)
Description copied from class:AbstractKFListAdd all the elements of the collection to the givenArrayList.- Specified by:
toArrayin classAbstractKFList<T>- Parameters:
allList- the list where all elements are added.
-
removeAllElementsOwnedBy
protected void removeAllElementsOwnedBy(Feature feature)
Description copied from class:AbstractKFListRemoved all elements owned by the givenFeature.- Specified by:
removeAllElementsOwnedByin classAbstractKFList<T>- Parameters:
feature- the owner of the elements to be removed
-
-