From 6dc270613534df75ee65e7d4260c6169e5fa3e71 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Tue, 19 Jan 2016 22:21:31 +0100 Subject: [PATCH] Add a bit of documentation in AbstractReadyIterator Some of the comments have been lost. This class implements a depth-first tree iterator, which does not use stack for keeping state, hence its code flow should be better commented. Change-Id: I604b0cef6f402c0e10403a7c29d272939ba2e8bd Signed-off-by: Robert Varga --- .../yang/data/impl/schema/tree/AbstractReadyIterator.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractReadyIterator.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractReadyIterator.java index 66a1cfe126..ccb49c8a88 100644 --- a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractReadyIterator.java +++ b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/AbstractReadyIterator.java @@ -31,7 +31,8 @@ abstract class AbstractReadyIterator { final AbstractReadyIterator process(final Version version) { // Walk all child nodes and remove any children which have not - // been modified. If a child + // been modified. If a child has children, we need to iterate + // through it via re-entering this method on the child iterator. while (children.hasNext()) { final ModifiedNode child = children.next(); final Optional childOperation = op.getChild(child.getIdentifier()); @@ -41,7 +42,7 @@ abstract class AbstractReadyIterator { final ModificationApplyOperation childOp = childOperation.get(); if (grandChildren.isEmpty()) { - + // The child is empty, seal it child.seal(childOp, version); if (child.getOperation() == LogicalOperation.NONE) { children.remove(); @@ -51,12 +52,15 @@ abstract class AbstractReadyIterator { } } + // We are done with this node, seal it. node.seal(op, version); // Remove from parent if we have one and this is a no-op if (node.getOperation() == LogicalOperation.NONE) { removeFromParent(); } + + // Sub-iteration complete, return back to parent return getParent(); } -- 2.36.6