package class9_Lab_ArrayOfGenerics; // Josiah Yoder, MSOE, 07 May 2015 import java.util.ArrayList; import java.util.List; /** * An alternative solution that allows using the inner class. * * From: http://stackoverflow.com/questions/8765211/how-do-i-get-an-inner-class-to-inherit-enclosing-class-generic-type * * @param Type of object held. */ public class TernarySearchTree { protected class TSTNode { // index values for accessing relatives array: protected static final int PARENT = 0, LOKID = 1, EQKID = 2, HIKID = 3; protected char splitchar; protected List> relatives; private U data; protected TSTNode(char splitchar, TSTNode parent) { this.splitchar = splitchar; relatives = new ArrayList>(); for (int i = 0; i < HIKID; ++i) { // Allocate 4 slots in relatives relatives.add(null); } relatives.set(PARENT, parent); } } private TSTNode node; // When you use it, pass T as U public TernarySearchTree() { node = new TSTNode<>(',', null); // When you use it, pass T as U } }