works.hacker.mptt.dyadic.DyadicRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mptt-jpa Show documentation
Show all versions of mptt-jpa Show documentation
Modified Preorder Tree Traversal - Java implementation using JPA
The newest version!
package works.hacker.mptt.dyadic;
import works.hacker.mptt.TreeRepository;
import java.util.Optional;
public interface DyadicRepository extends TreeRepository {
/**
* Internal method: Finds the youngest / last-added child of a given node.
*
* This method should not be called directly, but {@link DyadicRepository#addChild} depends on it.
*
* Given the following dyadic fractions nested intervals representation:
*
* .
* └── root [lft: 0/1 | rgt: 1/1]
* ├── child1 [lft: 0/1 | rgt: 1/2]
* │ ├── subChild1 [lft: 0/1 | rgt: 1/4]
* │ │ └── subSubChild [lft: 0/1 | rgt: 1/8]
* │ └── subChild2 [lft: 1/4 | rgt: 3/8]
* └── child2 [lft: 1/2 | rgt: 3/4]
* └── lastSubChild [lft: 1/2 | rgt: 5/8]
*
* When {@code repo.findYoungestChild(child1)}, then the right most child is
* {@code subChild-2 [lft: 1/4 | rgt: 3/8]}
*
* When {@code repo.findYoungestChild(root)}, then the right most child is
* {@code child2 [lft: 1/2 | rgt: 3/4]}
*
* @param parent the parent node for which to find the right most child
* @return an optional of the youngest / last-added child; or empty optional, if there are no children
*
* @see README
*/
Optional findYoungestChild(T parent);
}