@Test public void split13() throws Exception { Node<InvariantSpan> result = getK().split(2); assertEquals(new InvariantSpan(300, 2, documentHash), result.left.value); assertEquals(new InvariantSpan(302, 2, documentHash), result.right.value); }
public Node<T> split(long leftPartitionWidth) throws MalformedSpanException { if (leftPartitionWidth < 1) { throw new IllegalArgumentException("leftPartitionWidth must be greater than 0"); } if (!isLeaf()) { throw new MalformedSpanException("Can only split a leaf node"); } Node<T> parent = new Node<T>(leftPartitionWidth); StreamElementPartition<T> spans = (StreamElementPartition<T>) value.split(leftPartitionWidth); parent.left = new Node<T>(spans.getLeft()); parent.right = new Node<T>(spans.getRight()); parent.left.parent = parent; parent.right.parent = parent; if (parent.weight != leftPartitionWidth) { throw new IllegalStateException("node weight must equal variant position cutpoint"); } return parent; }
Node { public Node<T> split(long leftPartitionWidth) throws MalformedSpanException { if (leftPartitionWidth < 1) { throw new IllegalArgumentException("leftPartitionWidth must be greater than 0"); } if (!isLeaf()) { throw new MalformedSpanException("Can only split a leaf node"); } Node<T> parent = new Node<T>(leftPartitionWidth); StreamElementPartition<T> spans = (StreamElementPartition<T>) value.split(leftPartitionWidth); parent.left = new Node<T>(spans.getLeft()); parent.right = new Node<T>(spans.getRight()); parent.left.parent = parent; parent.right.parent = parent; if (parent.weight != leftPartitionWidth) { throw new IllegalStateException("node weight must equal variant position cutpoint"); } return parent; } }
Node { public Node<T> split(long leftPartitionWidth) throws MalformedSpanException { if (leftPartitionWidth < 1) { throw new IllegalArgumentException("leftPartitionWidth must be greater than 0"); } if (!isLeaf()) { throw new MalformedSpanException("Can only split a leaf node"); } Node<T> parent = new Node<T>(leftPartitionWidth); StreamElementPartition<T> spans = (StreamElementPartition<T>) value.split(leftPartitionWidth); parent.left = new Node<T>(spans.getLeft()); parent.right = new Node<T>(spans.getRight()); parent.left.parent = parent; parent.right.parent = parent; if (parent.weight != leftPartitionWidth) { throw new IllegalStateException("node weight must equal variant position cutpoint"); } return parent; } Node(long weight);  Node(T value); }
Node { public Node<T> split(long leftPartitionWidth) throws MalformedSpanException { if (leftPartitionWidth < 1) { throw new IllegalArgumentException("leftPartitionWidth must be greater than 0"); } if (!isLeaf()) { throw new MalformedSpanException("Can only split a leaf node"); } Node<T> parent = new Node<T>(leftPartitionWidth); StreamElementPartition<T> spans = (StreamElementPartition<T>) value.split(leftPartitionWidth); parent.left = new Node<T>(spans.getLeft()); parent.right = new Node<T>(spans.getRight()); parent.left.parent = parent; parent.right.parent = parent; if (parent.weight != leftPartitionWidth) { throw new IllegalStateException("node weight must equal variant position cutpoint"); } return parent; } Node(long weight);  Node(T value); long characterCount(); boolean isLeaf(); boolean isRightNode(); boolean isRoot(); Node<T> split(long leftPartitionWidth); @Override String toString(); }
Node { public Node<T> split(long leftPartitionWidth) throws MalformedSpanException { if (leftPartitionWidth < 1) { throw new IllegalArgumentException("leftPartitionWidth must be greater than 0"); } if (!isLeaf()) { throw new MalformedSpanException("Can only split a leaf node"); } Node<T> parent = new Node<T>(leftPartitionWidth); StreamElementPartition<T> spans = (StreamElementPartition<T>) value.split(leftPartitionWidth); parent.left = new Node<T>(spans.getLeft()); parent.right = new Node<T>(spans.getRight()); parent.left.parent = parent; parent.right.parent = parent; if (parent.weight != leftPartitionWidth) { throw new IllegalStateException("node weight must equal variant position cutpoint"); } return parent; } Node(long weight);  Node(T value); long characterCount(); boolean isLeaf(); boolean isRightNode(); boolean isRoot(); Node<T> split(long leftPartitionWidth); @Override String toString(); public boolean isRed; public Node<T> left; public Node<T> parent; public Node<T> right; public String tag; final T value; public long weight; }