import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException;
+import com.google.common.collect.ImmutableList;
+
/**
* Meta-container for the History Tree. This structure contains all the
* high-level data relevant to the tree.
return fLatestBranch.get(0);
}
+ /**
+ * Return the latest branch of the tree. That branch is immutable. Used for
+ * unit testing and debugging.
+ *
+ * @return The immutable latest branch
+ */
+ protected List<HTNode> getLatestBranch() {
+ return ImmutableList.copyOf(fLatestBranch);
+ }
+
// ------------------------------------------------------------------------
// HT_IO interface
// ------------------------------------------------------------------------
* No, this interval starts before the startTime of this node. We
* need to check recursively in parents if it can fit.
*/
- assert (indexOfNode >= 1);
tryInsertAtNode(interval, indexOfNode - 1);
return;
}
fLatestBranch.add(newRootNode);
// Create new coreNode
- for (int i = 1; i < depth + 1; i++) {
+ for (int i = 1; i < depth; i++) {
CoreNode prevNode = (CoreNode) fLatestBranch.get(i - 1);
CoreNode newNode = initNewCoreNode(prevNode.getParentSequenceNumber(),
splitTime + 1);
}
// Create the new leafNode
- CoreNode prevNode = (CoreNode) fLatestBranch.get(depth);
+ CoreNode prevNode = (CoreNode) fLatestBranch.get(depth - 1);
LeafNode newNode = initNewLeafNode(prevNode.getParentSequenceNumber(), splitTime + 1);
prevNode.linkNewChild(newNode);
fLatestBranch.add(newNode);
* Once we exit this loop, we should have found a children to follow. If
* we didn't, there's a problem.
*/
- assert (potentialNextSeqNb != currentNode.getSequenceNumber());
+ if (potentialNextSeqNb == currentNode.getSequenceNumber()) {
+ throw new IllegalStateException("No next child node found"); //$NON-NLS-1$
+ }
/*
* Since this code path is quite performance-critical, avoid iterating