public int Add(MyV2IPair myV2IPair) { if (_IsPosEnd()) { _Expand(); } data[currentPos] = new StorageTreeNode(myV2IPair.current); for (int i = 0; i < currentPos; i++) { if (data[i].data == myV2IPair.previous) { data[currentPos].father = data[i]; StorageTreeNode[] tLeavesArray = new StorageTreeNode[data[i].leavesCount + 1]; for (int j = 0; i < data[i].leavesCount; j++) { tLeavesArray[j] = data[i].leaves[j]; } tLeavesArray[data[i].leavesCount] = data[currentPos]; data[i].leaves = tLeavesArray; break; } } currentPos++; return(currentPos - 1); }
private void _Expand() { size *= 2; StorageTreeNode[] tdata = new StorageTreeNode[size]; for (int i = 0; i < currentPos; i++) { tdata[i] = data[i]; } data = tdata; }
public StorageTree() { size = 64; data = new StorageTreeNode[size]; currentPos = 0; }