"...pb138-film-database-group-project.git" did not exist on "27c5dcd6cb555ad73dd3e80d7752a7a54e819139"
Newer
Older

David Procházka
committed
import cz.muni.fi.disa.similarityoperators.cover.AbstractRepresentation.PrecomputedDistances;
import messif.objects.LocalAbstractObject;
import java.io.Serializable;
* Represents an internal node in MH-Tree.
class InternalNode extends Node implements Serializable {
/**
* Serialization ID
*/
private static final long serialVersionUID = 2L;

David Procházka
committed
protected InternalNode(PrecomputedDistances distances, InsertType insertType, ObjectToNodeDistance objectToNodeDistance, List<Node> children) {
super(distances, insertType, objectToNodeDistance);
/**
* Returns the list of child nodes.
*
* @return the list of child nodes
*/

David Procházka
committed
protected List<Node> getChildren() {
return children;
/**
* Returns the nearest child to the {@code object}.
*
* @param object object to which the distance is measured
* @return the nearest child to the {@code object}
*/

David Procházka
committed
protected Node getNearestChild(LocalAbstractObject object) {
Optional<Node> nearestChild = children
.stream()
.min(Comparator.comparing(child -> child.getDistance(object)));
return nearestChild.orElseThrow(() -> new IllegalStateException("Internal node has no children"));
/**
* Adds {@code object} into this node.
*
* @param object object to be added
*/

David Procházka
committed
protected void addObject(LocalAbstractObject object) {
/**
* Returns the list of objects stored in node's descendants.
*
* @return the list of objects stored in node's descendants
*/

David Procházka
committed
protected List<LocalAbstractObject> getObjects() {
.map(Node::getObjects)
.flatMap(Collection::stream)
/**
* Returns the height of this node.
*
* @return the height of this node
*/

David Procházka
committed
protected int getHeight() {
.mapToInt(Node::getHeight)
.summaryStatistics()
.getMax() + 1;
}
/**
* Adds this node and this node's descendants into {@code nodes}.
*

David Procházka
committed
protected void gatherNodes(List<Node> nodes) {

David Procházka
committed
children.forEach(child -> child.gatherNodes(nodes));
* Calls {@code gatherLeafNodes} on every child.

David Procházka
committed
protected void gatherLeafNodes(List<LeafNode> leafNodes) {
children.forEach(child -> child.gatherLeafNodes(leafNodes));