Package org.grp1.index
Class LeafNode
java.lang.Object
org.grp1.index.Node
org.grp1.index.LeafNode
- All Implemented Interfaces:
NodeChild
-
Field Summary
FieldsModifier and TypeFieldDescriptionRepresents the buckets of the nodeRepresents the keys of the nodeprivate final intRepresents the maximum number of keysprivate LeafNodeRepresents the next nodeprivate InternalNodeRepresents the node that points to this nodeprivate LeafNodeRepresents the previous node -
Constructor Summary
ConstructorsConstructorDescriptionLeafNode(LeafNode previous, LeafNode next, InternalNode parent, int maxNumOfKeys) Constructor to instantiate the leaf nodeLeafNode(LeafNode previous, LeafNode next, InternalNode parent, List<Integer> keys, List<Bucket> buckets, int maxNumOfKeys) Constructor to instantiate the leaf node -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()The function to clear the content of the nodevoiddelete(int index) The function that deletes an entry based on the indexgetBucket(int key) The function to return the bucket based on the keygetBucketByIndex(int index) The function to return the bucket by indexThe function to return the buckets of the nodegetChildAsNodeChild(int index) The function to return the child node as ChildNodeintgetKey()The function to return the minimum keyintgetKeyByIndex(int index) The function to return the key by indexgetKeys()The function to return the list of keys of the nodeintThe function to return the maximum number of keysintThe function to return the minimum number of keysgetNext()The function to return the next ndoeintgetRecordIndex(int key) intgetRecordIndexLowerBound(int key) The function to return the lower bound index of the nodevoidThe function to insert the new childvoidinsertAddress(Address newAddress, int key) The function to insert the address corresponding to the RecordbooleanisFull()The function to return the status of the nodevoidThe function to set the next nodevoidsetParent(InternalNode parent) The function to set the parent of the nodevoidsetPrevious(LeafNode previous) The function to set the previous nodevoidsetRecords(ArrayList<Integer> keys, ArrayList<Bucket> buckets) The function to set the records to the node using the addressintsize()The function to return the size of the nodesplitBucketList(int x) The function to split the bucket listsplitKeyList(int x) The function to split the key list
-
Field Details
-
maxNumOfKeys
private final int maxNumOfKeysRepresents the maximum number of keys -
keys
Represents the keys of the node -
buckets
Represents the buckets of the node -
parent
Represents the node that points to this node -
previous
Represents the previous node -
next
Represents the next node
-
-
Constructor Details
-
LeafNode
Constructor to instantiate the leaf node- Parameters:
previous- The previous nodenext- The next nodeparent- The parent nodemaxNumOfKeys- The maximum number of keys
-
LeafNode
public LeafNode(LeafNode previous, LeafNode next, InternalNode parent, List<Integer> keys, List<Bucket> buckets, int maxNumOfKeys) Constructor to instantiate the leaf node- Parameters:
previous- The previous nodenext- The next nodeparent- The parent nodekeys- The keys of the nodebuckets- The buckets of the nodemaxNumOfKeys- The maximum number of keys
-
-
Method Details
-
isFull
public boolean isFull()The function to return the status of the node -
size
public int size()The function to return the size of the node -
setPrevious
The function to set the previous node- Parameters:
previous- The previous node
-
setParent
The function to set the parent of the node -
setRecords
The function to set the records to the node using the address- Parameters:
keys- The keys of the nodebuckets- The buckets that will contain an address pointing to the record
-
insertAddress
The function to insert the address corresponding to the Record- Parameters:
newAddress- The address of the recordkey- The key of the record
-
insert
The function to insert the new child- Specified by:
insertin classNode- Parameters:
newChild- The new child to be inserted- Throws:
LeafFullException
-
getKey
public int getKey()The function to return the minimum key- Returns:
- The minimum key
-
getKeyByIndex
public int getKeyByIndex(int index) The function to return the key by index- Specified by:
getKeyByIndexin classNode- Parameters:
index- The index of the key- Returns:
- The corresponding index
-
getRecordIndex
public int getRecordIndex(int key) -
getRecordIndexLowerBound
public int getRecordIndexLowerBound(int key) The function to return the lower bound index of the node- Parameters:
key- The key of the record- Returns:
- The index lower bound corresponding to the key
-
clear
public void clear()The function to clear the content of the node -
getKeys
The function to return the list of keys of the node- Returns:
- The keys of the node
-
getBuckets
The function to return the buckets of the node- Returns:
- The buckets of the node
-
delete
public void delete(int index) The function that deletes an entry based on the index -
getBucket
The function to return the bucket based on the key- Parameters:
key- The key of the bucket- Returns:
- The bucket corresponding to the key
-
getBucketByIndex
The function to return the bucket by index- Parameters:
index- The index of the bucket- Returns:
- The bucket corresponding to the index
-
getChildAsNodeChild
The function to return the child node as ChildNode- Specified by:
getChildAsNodeChildin classNode- Parameters:
index- The index of the child node- Returns:
- The corresponding child node
-
getNext
The function to return the next ndoe- Returns:
- The next child ndoe
-
setNext
The function to set the next node- Parameters:
next- The next node
-
splitBucketList
The function to split the bucket list- Parameters:
x- The boundary between the left and right list- Returns:
- The split list of nodes
-
splitKeyList
The function to split the key list- Parameters:
x- The boundary between the left and right ist- Returns:
- The split list of nodes
-
getMaxNumOfKeys
public int getMaxNumOfKeys()The function to return the maximum number of keys- Returns:
- The maximum number of keys
-
getMinNumOfKeys
public int getMinNumOfKeys()The function to return the minimum number of keys- Returns:
- The minimum number of keys
-