Newer
Older

David Procházka
committed
import cz.muni.fi.disa.similarityoperators.cover.AbstractRepresentation.PrecomputedDistances;
import messif.buckets.BucketStorageException;
import messif.buckets.LocalBucket;
import messif.objects.LocalAbstractObject;
import java.io.Serializable;
import java.util.List;
public class LeafNode extends Node implements Serializable {
/**
* Serialization ID
*/
private static final long serialVersionUID = 1L;
/**
* Bucket for storing objects of the MH-Tree.
*/
private final LocalBucket bucket;

David Procházka
committed
protected LeafNode(PrecomputedDistances distances, LocalBucket bucket, InsertType insertType, ObjectToNodeDistance objectToNodeDistance) throws BucketStorageException {
super(distances, insertType, objectToNodeDistance);

David Procházka
committed
this.bucket.addObjects(distances.getObjects());
/**
* Adds {@code object} to the node's bucket.
*
* @param object object to be added
* @throws BucketStorageException addition of object into bucket exception
*/

David Procházka
committed
protected void addObject(LocalAbstractObject object) throws BucketStorageException {

David Procházka
committed
addObjectIntoHull(object);
/**
* Returns a list of objects in node's bucket.
*
* @return a list of objects in node's bucket
*/
public List<LocalAbstractObject> getObjects() {
List<LocalAbstractObject> objects = new ArrayList<>(bucket.getObjectCount());

David Procházka
committed
bucket
.getAllObjects()
.forEachRemaining(objects::add);
/**
* Returns the number of objects stored in node's bucket.
*
* @return the number of objects stored in node's bucket
*/

David Procházka
committed
protected int getObjectCount() {
return bucket.getObjectCount();
}
/**
* Returns the height of this node.
*
* @return the height of this node
*/

David Procházka
committed
protected int getHeight() {
/**
* Adds this node into {@code nodes}.
*
* @param nodes list of nodes
*/

David Procházka
committed
protected void gatherNodes(List<Node> nodes) {
nodes.add(this);
}
/**
* Adds this node into {@code leafNodes}.
*
* @param leafNodes list of leaf nodes
*/

David Procházka
committed
protected void gatherLeafNodes(List<LeafNode> leafNodes) {