Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MH-Tree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
disa
public
Hulls
MH-Tree
Commits
326edb28
There was an error fetching the commit references. Please try again later.
Verified
Commit
326edb28
authored
4 years ago
by
David Procházka
Browse files
Options
Downloads
Patches
Plain Diff
ADD: leaf node javadoc
parent
a2a7967f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mhtree/InternalNode.java
+6
-10
6 additions, 10 deletions
src/mhtree/InternalNode.java
src/mhtree/LeafNode.java
+58
-13
58 additions, 13 deletions
src/mhtree/LeafNode.java
with
64 additions
and
23 deletions
src/mhtree/InternalNode.java
+
6
−
10
View file @
326edb28
...
...
@@ -11,7 +11,7 @@ import java.util.stream.Collectors;
/**
* Represents internal node of MH-Tree, i.e. a non-leaf node.
*/
public
class
InternalNode
extends
Node
implements
Serializable
{
class
InternalNode
extends
Node
implements
Serializable
{
/**
* Serialization ID
...
...
@@ -98,7 +98,7 @@ public class InternalNode extends Node implements Serializable {
/**
* Adds this node and this node's descendants into {@code nodes}.
*
* @param nodes list of nodes
, where gathered nodes are added
* @param nodes list of nodes
*/
void
gatherNodes
(
List
<
Node
>
nodes
)
{
nodes
.
add
(
this
);
...
...
@@ -106,16 +106,12 @@ public class InternalNode extends Node implements Serializable {
}
/**
*
Returns a list of l
eaf
n
odes
under this node
.
*
Calls {@code gatherL
eaf
N
odes
} on every child
.
*
* @
return a
list of leaf node
under this node
* @
param leafNodes
list of leaf node
s
*/
List
<
LeafNode
>
getLeafNodes
()
{
return
children
.
stream
()
.
map
(
Node:
:
getLeafNodes
)
.
flatMap
(
Collection:
:
stream
)
.
collect
(
Collectors
.
toList
());
void
gatherLeafNodes
(
List
<
LeafNode
>
leafNodes
)
{
children
.
forEach
(
child
->
child
.
gatherLeafNodes
(
leafNodes
));
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/mhtree/LeafNode.java
+
58
−
13
View file @
326edb28
...
...
@@ -7,18 +7,23 @@ import messif.objects.LocalAbstractObject;
import
messif.objects.util.AbstractObjectIterator
;
import
java.io.Serializable
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
public
class
LeafNode
extends
Node
implements
Serializable
{
/**
* Represents leaf node of MH-Tree.
*/
class
LeafNode
extends
Node
implements
Serializable
{
/**
* Serialization ID
*/
private
static
final
long
serialVersionUID
=
1L
;
private
LocalBucket
bucket
;
/**
* Bucket for storing objects of the MH-Tree.
*/
private
final
LocalBucket
bucket
;
LeafNode
(
PrecomputedDistances
distances
,
LocalBucket
bucket
,
InsertType
insertType
,
ObjectToNodeDistance
objectToNodeDistance
)
throws
BucketStorageException
{
super
(
distances
,
insertType
,
objectToNodeDistance
);
...
...
@@ -27,26 +32,66 @@ public class LeafNode extends Node implements Serializable {
this
.
bucket
.
addObjects
(
distances
.
getObjects
());
}
public
void
addObject
(
LocalAbstractObject
object
)
throws
BucketStorageException
{
/**
* Adds {@code object} to the node's bucket.
*
* @param object object to be added
* @throws BucketStorageException addition of object into bucket exception
*/
void
addObject
(
LocalAbstractObject
object
)
throws
BucketStorageException
{
bucket
.
addObject
(
object
);
add
New
Object
(
object
);
addObject
IntoHull
(
object
);
}
public
Set
<
LocalAbstractObject
>
getObjects
()
{
Set
<
LocalAbstractObject
>
objects
=
new
HashSet
<>(
bucket
.
getObjectCount
());
/**
* Returns a list of objects in node's bucket.
*
* @return a list of objects in node's bucket
*/
List
<
LocalAbstractObject
>
getObjects
()
{
List
<
LocalAbstractObject
>
objects
=
new
ArrayList
<>(
bucket
.
getObjectCount
());
for
(
AbstractObjectIterator
<
LocalAbstractObject
>
it
=
bucket
.
getAllObjects
();
it
.
hasNext
();
)
for
(
AbstractObjectIterator
<
LocalAbstractObject
>
it
=
bucket
.
getAllObjects
();
it
.
hasNext
();
)
{
objects
.
add
(
it
.
next
());
}
return
objects
;
}
public
int
getHeight
()
{
/**
* Returns the number of objects stored in node's bucket.
*
* @return the number of objects stored in node's bucket
*/
int
getObjectCount
()
{
return
bucket
.
getObjectCount
();
}
/**
* Returns the height of this node.
*
* @return the height of this node
*/
int
getHeight
()
{
return
0
;
}
public
List
<
Node
>
getNodesOnLevel
(
int
level
)
{
return
Collections
.
singletonList
(
this
);
/**
* Adds this node into {@code nodes}.
*
* @param nodes list of nodes
*/
void
gatherNodes
(
List
<
Node
>
nodes
)
{
nodes
.
add
(
this
);
}
/**
* Adds this node into {@code leafNodes}.
*
* @param leafNodes list of leaf nodes
*/
void
gatherLeafNodes
(
List
<
LeafNode
>
leafNodes
)
{
leafNodes
.
add
(
this
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment