View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.geometry.core.partitioning.bsp;
    18
    19  import org.apache.commons.geometry.core.Point;
    20
    21  /** Interface for types that form the root of BSP subtrees. This includes trees
    22   * themselves as well as each node in a tree.
    23   * @param <P> Point implementation type
    24   * @param <N> Node implementation type
    25   * @see BSPTree
    26   */
    27  public interface BSPSubtree<P extends Point<P>, N extends BSPTree.Node<P, N>> {
    28
    29      /** Return the total number of nodes in the subtree.
    30       * @return the total number of nodes in the subtree.
    31       */
    32      int count();
    33
    34      /** The height of the subtree, ie the length of the longest downward path from
    35       * the subtree root to a leaf node. A leaf node has a height of 0.
    36       * @return the height of the subtree.
    37       */
    38      int height();
    39
    40      /** Accept a visitor instance, calling it with each node from the subtree.
    41       * @param visitor visitor called with each subtree node
    42       */
    43      void accept(BSPTreeVisitor<P, N> visitor);
    44
    45      /** Get an iterable for accessing the nodes in this subtree. This provides a simple
    46       * alternative to {@link #accept(BSPTreeVisitor)} for accessing tree nodes but is not
    47       * as powerful or flexible since the node iteration order is fixed.
    48       * @return an iterable for accessing the nodes in this subtree
    49       */
    50      Iterable<N> nodes();
    51  }