class TriNode
1: // Created by Frank M. Carrano and Timothy M. Henry.
2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey.
4: // Listing 19-1.
6: /** A class of nodes for a link-based 2-3 tree.
7: @file TriNode.h */
8:
9: #ifndef TRI_NODE_
10: #define TRI_NODE_
12: template<class ItemType>
13: class TriNode
14: {
15: private:
16: ItemType smallItem; // Data portion
17: ItemType largeItem; // Data portion
18: std::shared_ptr<TriNode<ItemType>> leftChildPtr; // Left-child pointer
19: std::shared_ptr<TriNode<ItemType>> midChildPtr; // Middle-child pointer
20: std::shared_ptr<TriNode<ItemType>> rightChildPtr; // Right-child pointer
21:
22: public:
23: TriNode();
24:
25: bool isLeaf() const;
26: bool isTwoNode() const;
27: bool isThreeNode() const;
28:
29: ItemType getSmallItem() const;
30: ItemType getLargeItem() const;
31:
32: void setSmallItem(const ItemType& anItem);
33: void setLargeItem(const ItemType& anItem);
34:
35: auto getLeftChildPtr() const;
36: auto getMidChildPtr() const;
37: auto getRightChildPtr() const;
38:
39: void setLeftChildPtr(std::shared_ptr<TriNode<ItemType>> leftPtr);
40: void setMidChildPtr(std::shared_ptr<TriNode<ItemType>> midPtr);
41: void setRightChildPtr(std::shared_ptr<TriNode<ItemType>> rightPtr);
42: }; // end TriNode
43: #include “TriNode.cpp”
44: #endif