Class InternalNode

java.lang.Object
org.grp1.index.Node
org.grp1.index.InternalNode
All Implemented Interfaces:
NodeChild

public class InternalNode extends Node
  • Field Details

    • maxNumOfKeys

      private final int maxNumOfKeys
      Represents the maximum number of keys that the internal node can contain
    • keys

      private List<Integer> keys
      Represents the keys of the node
    • children

      private List<Node> children
      Represents the children of the nodes
    • parent

      private InternalNode parent
      Represents the parent of the node
  • Constructor Details

    • InternalNode

      public InternalNode(List<Integer> keys, List<Node> children, int maxNumOfKeys)
      Constructor to instantiate the node
      Parameters:
      keys - The keys of the node
      children - The children that this node points to
      maxNumOfKeys - 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
      Specified by:
      isFull in class Node
      Returns:
      The status of the node whether it is full or not
    • size

      public int size()
      The function to get the size of the node
      Specified by:
      size in class Node
      Returns:
      The size of the node
    • getKeys

      public List<Integer> getKeys()
      The function to return all the keys of the node
      Returns:
      The keys of the node
    • getChildren

      public List<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
      Specified by:
      delete in class Node
      Parameters:
      index - The index of the entry to be deleted
    • setParent

      public void setParent(InternalNode parent)
      The function to set the parent of the node
      Specified by:
      setParent in class Node
      Parameters:
      parent - The node that points to this node
    • setChildren

      public void setChildren(ArrayList<Integer> keys, ArrayList<Node> children)
      The function to set the children of the node
      Parameters:
      keys - The keys that form range of keys for the children
      children - 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:
      getKeyByIndex in class Node
      Parameters:
      index - The index of the key
      Returns:
      The key corresponding to the index
    • getChild

      public Node getChild(int key)
      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

      public Node getChildByIndex(int index)
      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

      public NodeChild getChildAsNodeChild(int index)
      The function to return the child node based on index as NodeChild
      Specified by:
      getChildAsNodeChild in class Node
      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

      public void insert(NodeChild newChild)
      The function to insert the new child
      Specified by:
      insert in class Node
      Parameters:
      newChild - The node corresponding to the new node to be inserted
    • splitChildrenList

      public List<Node> splitChildrenList(int x)
      The function to split the children list
      Parameters:
      x - The boundary between the left and right list
      Returns:
      The split list of nodes
    • splitKeyList

      public ArrayList<Integer> splitKeyList(int x)
      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