/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { Skip, visitBipartiteIterableTreeWithState,
// eslint-disable-next-line import/no-internal-modules
 } from "../../../feature-libraries/flex-tree/navigation.js";
/**
 * Simpler version of visitIterableTree, but uses more memory.
 */
function visitIterableTree2(root, visitor) {
    const queue = [root];
    let next;
    while ((next = queue.pop())) {
        if (visitor(next) !== Skip) {
            for (const child of next) {
                queue.push(child);
            }
        }
    }
}
/**
 * Simpler version of visitIterableTree, but recursive.
 */
function visitIterableTreeRecursive(root, visitor) {
    if (visitor(root) !== Skip) {
        for (const child of root) {
            visitIterableTreeRecursive(child, visitor);
        }
    }
}
// Examples
function test(root) {
    // Count depth in nodes:
    let depth = 0;
    visitBipartiteIterableTreeWithState(root, 0, (field) => field.boxedIterator(), (node) => node.boxedIterator(), (field, n) => n, (node, n) => {
        depth = Math.max(n, depth);
        return n + 1;
    });
    // Construct all paths
    visitBipartiteIterableTreeWithState(root, undefined, (field) => field.boxedIterator(), (node) => node.boxedIterator(), (field, parent) => ({
        parent,
        field: field.key,
    }), (node, parent) => ({
        parent: parent.parent,
        parentField: parent.field,
        parentIndex: node.parentField.index,
    }));
}
//# sourceMappingURL=navigation.spec.js.map