Package org.eclipse.emf.common.util
Class AbstractTreeIterator<E>
java.lang.Object
java.util.AbstractCollection<Iterator<? extends E>>
java.util.AbstractList<Iterator<? extends E>>
org.eclipse.emf.common.util.AbstractEList<Iterator<? extends E>>
org.eclipse.emf.common.util.BasicEList<Iterator<? extends E>>
org.eclipse.emf.common.util.AbstractTreeIterator<E>
- All Implemented Interfaces:
Serializable,Cloneable,Iterable<Iterator<? extends E>>,Collection<Iterator<? extends E>>,Iterator<E>,List<Iterator<? extends E>>,RandomAccess,SequencedCollection<Iterator<? extends E>>,EList<Iterator<? extends E>>,TreeIterator<E>
public abstract class AbstractTreeIterator<E>
extends BasicEList<Iterator<? extends E>>
implements TreeIterator<E>
An extensible tree iterator implementation
that iterates over an object, it's children, their children, and so on.
Clients need only implement
getChildren
in order to implement a fully functional tree iterator.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.emf.common.util.BasicEList
BasicEList.BasicIndexOutOfBoundsException, BasicEList.EIterator<E1>, BasicEList.EListIterator<E1>, BasicEList.FastCompare<E>, BasicEList.NonResolvingEIterator<E1>, BasicEList.NonResolvingEListIterator<E1>, BasicEList.UnmodifiableEList<E> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the first call to next returns the initial root object or begins with the first child of the root object.The iterator that would be cut short by a call toprune().The iterator to which aremove()call will delegated.protected ObjectThe root object for which the iteration is initiated.Fields inherited from class org.eclipse.emf.common.util.BasicEList
data, sizeFields inherited from class java.util.AbstractList
modCount -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTreeIterator(E object) Creates an instance that iterates over an object, it's children, their children, and so on.AbstractTreeIterator(Object object, boolean includeRoot) Creates and instance that iterates over an object (but only ifincludeRootistrue), it's children, their children, and so on. -
Method Summary
Modifier and TypeMethodDescriptiongetChildren(Object object) Returns the iterator that yields the children of the object.booleanhasNext()Returns whether there are more elements.next()Returns the next object and advances the iterator.voidprune()Prunes the iterator so that it skips over all the nodes below the most recent result of callingnext().voidremove()Removes the last object returned bynext()from the underlying tree; it's an optional operation.Methods inherited from class org.eclipse.emf.common.util.BasicEList
addAllUnique, addAllUnique, addAllUnique, addAllUnique, addUnique, addUnique, assign, basicGet, basicList, clear, clone, contains, data, get, grow, indexOf, isEmpty, lastIndexOf, move, newData, primitiveGet, remove, setData, setUnique, shrink, size, toArray, toArrayMethods inherited from class org.eclipse.emf.common.util.AbstractEList
add, add, addAll, addAll, basicIterator, basicListIterator, basicListIterator, canContainNull, didAdd, didChange, didClear, didMove, didRemove, didSet, equalObjects, equals, getDuplicates, getNonDuplicates, hashCode, isUnique, iterator, listIterator, listIterator, move, remove, removeAll, resolve, retainAll, set, toString, useEquals, validateMethods inherited from class java.util.AbstractList
removeRange, subListMethods inherited from class java.util.AbstractCollection
containsAllMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Iterator
forEachRemainingMethods inherited from interface java.util.List
addFirst, addLast, containsAll, getFirst, getLast, removeFirst, removeLast, replaceAll, reversed, sort, spliterator, subList
-
Field Details
-
includeRoot
protected boolean includeRootWhether the first call to next returns the initial root object or begins with the first child of the root object. -
object
The root object for which the iteration is initiated. -
nextPruneIterator
The iterator that would be cut short by a call toprune(). -
nextRemoveIterator
The iterator to which aremove()call will delegated.
-
-
Constructor Details
-
AbstractTreeIterator
Creates an instance that iterates over an object, it's children, their children, and so on.- Parameters:
object- the root object of the tree.
-
AbstractTreeIterator
Creates and instance that iterates over an object (but only if
includeRootistrue), it's children, their children, and so on.If
includeRootistrue, theobjectis expected to be of the typeE.
-
-
Method Details
-
getChildren
Returns the iterator that yields the children of the object.- Parameters:
object- the object for which children are required.- Returns:
- the iterator that yields the children.
-
hasNext
public boolean hasNext()Returns whether there are more elements. -
next
Returns the next object and advances the iterator. -
remove
public void remove()Removes the last object returned bynext()from the underlying tree; it's an optional operation.- Specified by:
removein interfaceIterator<E>- Throws:
IllegalStateException- ifnexthas not yet been called or has been called only the yield the root object, orremovehas already been called after the last call to thenextmethod.
-
prune
public void prune()Prunes the iterator so that it skips over all the nodes below the most recent result of callingnext().- Specified by:
prunein interfaceTreeIterator<E>
-