Class FlatTreeNode<V>

    • Method Detail

      • root

        public FlatTreeNode<Vroot()
        Returns the root of the tree that contains this node. The root is the ancestor with no parent. This implementation have a runtime complexity of O(1).
        Specified by:
        root in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        the root of the tree that contains this node
      • isRoot

        public boolean isRoot()
        Description copied from interface: Tree
        Returns true if this node is the root of the tree.
        Specified by:
        isRoot in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        true if this node is the root of its tree, false otherwise
      • value

        public V value()
        Description copied from interface: Tree
        Return the value of the current Tree node. The value may be null.
        Specified by:
        value in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        the value of the current Tree node
      • parent

        public Optional<FlatTreeNode<V>> parent()
        Description copied from interface: Tree
        Return the parent node of this tree node.
        Specified by:
        parent in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        the parent node, or Optional.empty() if this node is the root of the tree
      • childAt

        public FlatTreeNode<VchildAt​(int index)
        Description copied from interface: Tree
        Return the child node with the given index.
        Specified by:
        childAt in interface Tree<V,​FlatTreeNode<V>>
        Parameters:
        index - the child index
        Returns:
        the child node with the given index
      • childCount

        public int childCount()
        Description copied from interface: Tree
        Return the number of children this tree node consists of.
        Specified by:
        childCount in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        the number of children this tree node consists of
      • childOffset

        public int childOffset()
        Return the index of the first child node in the underlying node array. -1 is returned if this node is a leaf.
        Specified by:
        childOffset in interface FlatTree<V,​FlatTreeNode<V>>
        Returns:
        Return the index of the first child node in the underlying node array, or -1 if this node is a leaf
      • flattenedNodes

        public ISeq<FlatTreeNode<V>> flattenedNodes()
        Description copied from interface: FlatTree
        Return the whole flattened tree values in breadth-first order. This is equivalent to
        final ISeq<T> seq = getRoot().breadthFirstStream() .collect(ISeq.toISeq());
        Specified by:
        flattenedNodes in interface FlatTree<V,​FlatTreeNode<V>>
        Returns:
        the flattened tree values in breadth-first order
      • breadthFirstIterator

        public Iterator<FlatTreeNode<V>> breadthFirstIterator()
        Description copied from interface: Tree
        Return an iterator that traverses the subtree rooted at this node in breadth-first order. The first node returned by the iterator is this node.

        Modifying the tree by inserting, removing, or moving a node invalidates any iterator created before the modification.

        Specified by:
        breadthFirstIterator in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        an iterator for traversing the tree in breadth-first order
        See Also:
        Tree.depthFirstIterator()
      • map

        public <B> ISeq<B> map​(Function<? super FlatTreeNode<V>,​? extends B> mapper)
        Return a sequence of all mapped nodes of the whole underlying tree. This is a convenient method for
        final ISeq<B> seq = stream() .map(mapper) .collect(ISeq.toISeq())
        Type Parameters:
        B - the mapped type
        Parameters:
        mapper - the mapper function
        Returns:
        a sequence of all mapped nodes
      • identical

        public boolean identical​(Tree<?,​?> other)
        Description copied from interface: Tree
        Tests whether this node is the same as the other node. The default implementation returns the object identity, this == other, of the two objects, but other implementations may use different criteria for checking the identity.
        Specified by:
        identical in interface Tree<V,​FlatTreeNode<V>>
        Parameters:
        other - the other node
        Returns:
        true if the other node is the same as this node.
      • size

        public int size()
        Description copied from interface: Tree
        Return the number of nodes of this node (sub-tree).
        Specified by:
        size in interface Tree<V,​FlatTreeNode<V>>
        Returns:
        the number of nodes of this node (sub-tree)
      • of

        @Deprecated(since="6.1",
                    forRemoval=true)
        public static <V> FlatTreeNode<V> of​(Tree<? extends V,​?> tree)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Use ofTree(Tree) instead
        Create a new, immutable FlatTreeNode from the given tree.
        Type Parameters:
        V - the tree value types
        Parameters:
        tree - the source tree
        Returns:
        a new FlatTreeNode from the given tree
        Throws:
        NullPointerException - if the given tree is null
      • ofTree

        public static <V> FlatTreeNode<V> ofTree​(Tree<? extends V,​?> tree)
        Create a new, immutable FlatTreeNode from the given tree.
        Type Parameters:
        V - the tree value types
        Parameters:
        tree - the source tree
        Returns:
        a new FlatTreeNode from the given tree
        Throws:
        NullPointerException - if the given tree is null