package tree234; /** * Represents the abstract state of a 2-3-4 tree. * @author Dung X. Nguyen - Copyright 2000 - All Rights Reserved. */ abstract class ANode234 { /** * Inserts an Integer into the owner tree without duplication. * @param n != null. * @param owner the owner of this ANode234. */ abstract void insert (Integer n, Tree234 owner); /** * Helps the owner's parent tree insert data, using the other two owner's siblings if necessary. * @param ownerParent the parent of owner. * @param ownerSib1 one of the two siblings of owner. * @param ownerSib2 the sibling of ownerSib1 and owner. * @param n an Integer to be properly inserted into ownerParent. * @param owner the owner of this ANode234 */ abstract void helpParentInsert (Tree234 ownerParent, Tree234 ownerSib1, Tree234 ownerSib2, Integer n, Tree234 owner); /** * Helps the owner's parent insert data, using the one remaining owner's sibling if necessary. * @param ownerParent the parent of owner. * @param ownerSib owner's sibling * @param n an Integer to be properly inserted into ownerParent. * @param owner the owner of this ANode234 */ abstract void helpParentInsert (Tree234 ownerParent, Tree234 ownerSib, Integer n, Tree234 owner); /** * Helps the owner's parent insert data with the knowledge that all the owner's siblings are empty . * @param ownerParent the parent of owner. * @param n an Integer to be properly inserted into ownerParent. * @param owner the owner of this ANode234 */ abstract void helpParentInsert (Tree234 ownerParent, Integer n, Tree234 owner); /** * Inserts data into owner when this ANode234 is a leaf node. * @param n an Integer to be properly inserted into owner. * @param owner the owner of this ANode234 */ abstract void insertAsLeaf (Integer n, Tree234 owner); /** * Inserts data into the owner when this Anode234 is NOT a leaf node. * @param n != root data. * @param owner the owner of this ANode234 */ abstract void insertNotAsLeaf (Integer n, Tree234 owner); /** * The owner of this ANode234 is is a subtree of a given parent tree. * Inserts n into the owner tree. Splits and re-attaches to the owner's parent if necessary. * @param ownerParent the parent of this tree. * @param n an Integer to be properly inserted into owner. * @param owner the owner of this ANode234 */ abstract void insertAsChild (Tree234 ownerParent, Integer n, Tree234 owner); /** * Attaches the 3 components a 2-node to the owner tree in the proper order. * The owner must be the parent of a Tree234. * @param lTree a 2-3-4 tree whose elements are less than n. * @param n a data element. * @param rTree a 2-3-4 tree whose elements are greater than n. * @param owner the owner of this ANode234, must be the parent of a Tree234. */ abstract void attach (Tree234 lTree, Integer n, Tree234 rTree, Tree234 owner); }