Skip to content
Snippets Groups Projects
Verified Commit 7848d415 authored by David Procházka's avatar David Procházka
Browse files

ADD: optimization when the new node is build on every object, public methods

parent 0812ae51
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ import java.util.Collection; ...@@ -11,7 +11,7 @@ import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
abstract class Node implements Serializable { public abstract class Node implements Serializable {
/** /**
* Serialization ID * Serialization ID
...@@ -38,9 +38,32 @@ abstract class Node implements Serializable { ...@@ -38,9 +38,32 @@ abstract class Node implements Serializable {
.flatMap(Collection::stream) .flatMap(Collection::stream)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (nodes.size() == distances.getObjectCount()) {
return new InternalNode(distances, insertType, objectToNodeDistance, nodes);
}
return new InternalNode(distances.getSubset(objects), insertType, objectToNodeDistance, nodes); return new InternalNode(distances.getSubset(objects), insertType, objectToNodeDistance, nodes);
} }
/**
* Returns a list of hull objects.
*
* @return a list of hull objects
*/
public List<LocalAbstractObject> getHullObjects() {
return hull.getHull();
}
/**
* Returns true if the {@code object} is covered.
*
* @param object the object to be checked
* @return true if the {@code object} is covered.
*/
public boolean isCovered(LocalAbstractObject object) {
return hull.isExternalCovered(object);
}
@Override @Override
public String toString() { public String toString() {
return "Node{hull=" + hull + '}'; return "Node{hull=" + hull + '}';
...@@ -66,10 +89,6 @@ abstract class Node implements Serializable { ...@@ -66,10 +89,6 @@ abstract class Node implements Serializable {
return !isLeaf(); return !isLeaf();
} }
protected List<LocalAbstractObject> getHullObjects() {
return hull.getHull();
}
protected int getHullObjectCount() { protected int getHullObjectCount() {
return hull.getRepresentativesCount(); return hull.getRepresentativesCount();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment