Example usage for com.google.common.collect TreeTraverser children

List of usage examples for com.google.common.collect TreeTraverser children

Introduction

In this page you can find the example usage for com.google.common.collect TreeTraverser children.

Prototype

public abstract Iterable<T> children(T root);

Source Link

Document

Returns the children of the specified node.

Usage

From source file:com.github.rconner.anansi.PostOrderIterator.java

PostOrderIterator(final T root, final TreeTraverser<T> adjacency) {
    this.adjacency = adjacency;
    stack = PersistentList.of(new Move<T>(root, adjacency.children(root).iterator()));
}

From source file:com.android.build.gradle.shrinker.FullRunShrinker.java

private void handleInterfaceInheritance(@NonNull Set<T> interfaceInheritance) {
    for (final T klass : interfaceInheritance) {
        mExecutor.execute(new Callable<Void>() {
            @Override/*from www .j a  v a  2  s  . co m*/
            public Void call() throws Exception {
                TreeTraverser<T> interfaceTraverser = TypeHierarchyTraverser.interfaces(mGraph,
                        mShrinkerLogger);

                if ((mGraph.getModifiers(klass) & Opcodes.ACC_INTERFACE) != 0) {

                    // The "children" name is unfortunate: in the type hierarchy tree traverser,
                    // these are the interfaces that klass (which is an interface itself)
                    // extends (directly).
                    Iterable<T> superinterfaces = interfaceTraverser.children(klass);

                    for (T superinterface : superinterfaces) {
                        if (!mGraph.isLibraryClass(superinterface)) {
                            // Add the arrow going "down", from the superinterface to this one.
                            mGraph.addDependency(superinterface, klass, DependencyType.SUPERINTERFACE_KEPT);
                        } else {
                            // The superinterface is part of the SDK, so it's always kept. As
                            // long as there's any class that implements this interface, it
                            // needs to be kept.
                            mGraph.incrementAndCheck(klass, DependencyType.SUPERINTERFACE_KEPT,
                                    CounterSet.SHRINK);
                        }
                    }
                }

                for (T iface : interfaceTraverser.preOrderTraversal(klass)) {
                    if (!mGraph.isLibraryClass(iface)) {
                        mGraph.addDependency(klass, iface, DependencyType.INTERFACE_IMPLEMENTED);
                    }
                }

                return null;
            }
        });
    }
}