Package org.jetbrains.mps.util
Class BreadthConceptHierarchyIterator
- java.lang.Object
-
- org.jetbrains.mps.util.BreadthConceptHierarchyIterator
-
- All Implemented Interfaces:
Iterable<SAbstractConcept>
,Iterator<SAbstractConcept>
public class BreadthConceptHierarchyIterator extends Object implements Iterable<SAbstractConcept>, Iterator<SAbstractConcept>
Iterates hierarchy of concepts, breadth-first. Iterator doesn't support removals. Return values are not unique, e.g. if an interface is implemented by few concepts, it is reported several times. Wrap withUniqueIterator
if necessary. Given ConceptA implements I1, I2 and ConceptB extends ConceptA implements I3, I4; Interface I3 extends I5; Interface I5 extends I1; and ConceptB as starting point, yields: { ConceptB, I3, I4 } - level 0 for ConceptB, { ConceptA, I1, I2 } - level 1 from ConceptA , { I5 } level 1 from I3, {I1} - level 2 from I5. Note, this class is similar to what used to beorg.jetbrains.mps.openapi.language.SConceptUtil
, except for explicit walk algorithm and OOP-friendly style.
-
-
Constructor Summary
Constructors Constructor Description BreadthConceptHierarchyIterator(SAbstractConcept start)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
Iterator<SAbstractConcept>
iterator()
SAbstractConcept
next()
void
remove()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Constructor Detail
-
BreadthConceptHierarchyIterator
public BreadthConceptHierarchyIterator(@NotNull SAbstractConcept start)
-
-
Method Detail
-
iterator
@NotNull public Iterator<SAbstractConcept> iterator()
- Specified by:
iterator
in interfaceIterable<SAbstractConcept>
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceIterator<SAbstractConcept>
-
next
public SAbstractConcept next()
- Specified by:
next
in interfaceIterator<SAbstractConcept>
-
remove
public void remove()
- Specified by:
remove
in interfaceIterator<SAbstractConcept>
-
-