Package org.grp1.index
Class InternalNode
java.lang.Object
org.grp1.index.Node
org.grp1.index.InternalNode
- All Implemented Interfaces:
NodeChild
-
Field Summary
FieldsModifier and TypeFieldDescriptionRepresents the children of the nodesRepresents the keys of the nodeprivate final intRepresents the maximum number of keys that the internal node can containprivate InternalNodeRepresents the parent of the node -
Constructor Summary
ConstructorsConstructorDescriptionInternalNode(List<Integer> keys, List<Node> children, int maxNumOfKeys) Constructor to instantiate the node -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()The function to clear the contents of the nodevoiddelete(int index) The function helper to delete the entry based on the indexgetChild(int key) The function to return the child based on the keygetChildAsNodeChild(int index) The function to return the child node based on index as NodeChildgetChildByIndex(int index) The function to return the child based on the indexintgetChildIndex(int key) The function to return the child index by the keyThe function to return the children of the nodeintgetKey()The function to return the minimum value of the keyintgetKeyByIndex(int index) The function to return the key by indexgetKeys()The function to return all the keys of the nodeintThe function to return the maximum number of keysintThe function to return the minimum number of keysvoidThe function to insert the new childbooleanisFull()The function to indicate whether the node is at full capacityvoidsetChildren(ArrayList<Integer> keys, ArrayList<Node> children) The function to set the children of the nodevoidsetParent(InternalNode parent) The function to set the parent of the nodeintsize()The function to get the size of the nodesplitChildrenList(int x) The function to split the children listsplitKeyList(int x) The function to split the key listbooleanupdateKey(int index) The function to update the key
-
Field Details
-
maxNumOfKeys
private final int maxNumOfKeysRepresents the maximum number of keys that the internal node can contain -
keys
Represents the keys of the node -
children
Represents the children of the nodes -
parent
Represents the parent of the node
-
-
Constructor Details
-
InternalNode
Constructor to instantiate the node- Parameters:
keys- The keys of the nodechildren- The children that this node points tomaxNumOfKeys- The maximum number of keys that this node can contain
-
-
Method Details
-
isFull
public boolean isFull()The function to indicate whether the node is at full capacity -
size
public int size()The function to get the size of the node -
getKeys
The function to return all the keys of the node- Returns:
- The keys of the node
-
getChildren
The function to return the children of the node- Returns:
- The children of the node
-
clear
public void clear()The function to clear the contents of the node -
delete
public void delete(int index) The function helper to delete the entry based on the index -
setParent
The function to set the parent of the node -
setChildren
The function to set the children of the node- Parameters:
keys- The keys that form range of keys for the childrenchildren- The nodes to point from this node
-
getKey
public int getKey()The function to return the minimum value of the key- Returns:
- The minimum value of the 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 key corresponding to the index
-
getChild
The function to return the child based on the key- Parameters:
key- The key of the child- Returns:
- The child corresponding to the key
-
getChildByIndex
The function to return the child based on the index- Parameters:
index- The index of the child- Returns:
- The child corresponding to the index
-
getChildAsNodeChild
The function to return the child node based on index as NodeChild- Specified by:
getChildAsNodeChildin classNode- Parameters:
index- The index of the child node- Returns:
- The child corresponding to the index in the NodeChild form
-
getChildIndex
public int getChildIndex(int key) The function to return the child index by the key- Parameters:
key- The key of the child- Returns:
- The corresponding child of the node based on the key
-
insert
The function to insert the new child -
splitChildrenList
The function to split the children 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
-
updateKey
public boolean updateKey(int index) The function to update the key- Parameters:
index- The corresponding index of the node to be updated- Returns:
- The status whether the new key is updated
-
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
-