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

FIX: moved java docs to abstract methods

parent b5168746
No related branches found
No related tags found
No related merge requests found
...@@ -51,21 +51,11 @@ class InternalNode extends Node implements Serializable { ...@@ -51,21 +51,11 @@ class InternalNode extends Node implements Serializable {
return nearestChild.orElseThrow(() -> new IllegalStateException("Internal node has no children")); return nearestChild.orElseThrow(() -> new IllegalStateException("Internal node has no children"));
} }
/**
* Adds {@code object} into this node.
*
* @param object object to be added
*/
@Override @Override
protected void addObject(LocalAbstractObject object) { protected void addObject(LocalAbstractObject object) {
addObjectIntoHull(object); addObjectIntoHull(object);
} }
/**
* Returns the list of objects stored in node's descendants.
*
* @return the list of objects stored in node's descendants
*/
@Override @Override
protected List<LocalAbstractObject> getObjects() { protected List<LocalAbstractObject> getObjects() {
return children return children
...@@ -75,11 +65,6 @@ class InternalNode extends Node implements Serializable { ...@@ -75,11 +65,6 @@ class InternalNode extends Node implements Serializable {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
/**
* Returns the height of this node.
*
* @return the height of this node
*/
@Override @Override
protected int getHeight() { protected int getHeight() {
return children return children
...@@ -89,22 +74,12 @@ class InternalNode extends Node implements Serializable { ...@@ -89,22 +74,12 @@ class InternalNode extends Node implements Serializable {
.getMax() + 1; .getMax() + 1;
} }
/**
* Adds this node and this node's descendants into {@code nodes}.
*
* @param nodes list of nodes
*/
@Override @Override
protected void gatherNodes(List<Node> nodes) { protected void gatherNodes(List<Node> nodes) {
nodes.add(this); nodes.add(this);
children.forEach(child -> child.gatherNodes(nodes)); children.forEach(child -> child.gatherNodes(nodes));
} }
/**
* Calls {@code gatherLeafNodes} on every child.
*
* @param leafNodes list of leaf nodes
*/
@Override @Override
protected void gatherLeafNodes(List<LeafNode> leafNodes) { protected void gatherLeafNodes(List<LeafNode> leafNodes) {
children.forEach(child -> child.gatherLeafNodes(leafNodes)); children.forEach(child -> child.gatherLeafNodes(leafNodes));
......
...@@ -33,22 +33,20 @@ public class LeafNode extends Node implements Serializable { ...@@ -33,22 +33,20 @@ public class LeafNode extends Node implements Serializable {
} }
/** /**
* Adds {@code object} to the node's bucket. * Returns the number of objects stored in node's bucket.
* *
* @param object object to be added * @return the number of objects stored in node's bucket
* @throws BucketStorageException addition of object into bucket exception
*/ */
protected int getObjectCount() {
return bucket.getObjectCount();
}
@Override @Override
protected void addObject(LocalAbstractObject object) throws BucketStorageException { protected void addObject(LocalAbstractObject object) throws BucketStorageException {
bucket.addObject(object); bucket.addObject(object);
addObjectIntoHull(object); addObjectIntoHull(object);
} }
/**
* Returns a list of objects in node's bucket.
*
* @return a list of objects in node's bucket
*/
@Override @Override
public List<LocalAbstractObject> getObjects() { public List<LocalAbstractObject> getObjects() {
List<LocalAbstractObject> objects = new ArrayList<>(bucket.getObjectCount()); List<LocalAbstractObject> objects = new ArrayList<>(bucket.getObjectCount());
...@@ -60,40 +58,16 @@ public class LeafNode extends Node implements Serializable { ...@@ -60,40 +58,16 @@ public class LeafNode extends Node implements Serializable {
return objects; return objects;
} }
/**
* Returns the number of objects stored in node's bucket.
*
* @return the number of objects stored in node's bucket
*/
protected int getObjectCount() {
return bucket.getObjectCount();
}
/**
* Returns the height of this node.
*
* @return the height of this node
*/
@Override @Override
protected int getHeight() { protected int getHeight() {
return 0; return 0;
} }
/**
* Adds this node into {@code nodes}.
*
* @param nodes list of nodes
*/
@Override @Override
protected void gatherNodes(List<Node> nodes) { protected void gatherNodes(List<Node> nodes) {
nodes.add(this); nodes.add(this);
} }
/**
* Adds this node into {@code leafNodes}.
*
* @param leafNodes list of leaf nodes
*/
@Override @Override
protected void gatherLeafNodes(List<LeafNode> leafNodes) { protected void gatherLeafNodes(List<LeafNode> leafNodes) {
leafNodes.add(this); leafNodes.add(this);
......
...@@ -99,14 +99,40 @@ public abstract class Node implements Serializable { ...@@ -99,14 +99,40 @@ public abstract class Node implements Serializable {
} }
} }
/**
* Adds {@code object} into this node, possibly adding {@code object} to the bucket.
*
* @param object object to be added
* @throws BucketStorageException bucket exception
*/
protected abstract void addObject(LocalAbstractObject object) throws BucketStorageException; protected abstract void addObject(LocalAbstractObject object) throws BucketStorageException;
/**
* Returns objects from buckets, such that the leaf node is descendants of the current node.
*
* @return objects from buckets, such that the leaf node is descendants of the current node.
*/
protected abstract List<LocalAbstractObject> getObjects(); protected abstract List<LocalAbstractObject> getObjects();
/**
* Returns the height of this node.
*
* @return the height of this node
*/
protected abstract int getHeight(); protected abstract int getHeight();
/**
* Adds this node and descendants into {@code nodes}.
*
* @param nodes list of nodes
*/
protected abstract void gatherNodes(List<Node> nodes); protected abstract void gatherNodes(List<Node> nodes);
/**
* Adds every descendant leaf node into {@code leafNodes}.
*
* @param leafNodes list of leaf nodes
*/
protected abstract void gatherLeafNodes(List<LeafNode> leafNodes); protected abstract void gatherLeafNodes(List<LeafNode> leafNodes);
private void insertGreedy(LocalAbstractObject object) { private void insertGreedy(LocalAbstractObject object) {
......
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