Package com.google.common.collect.BstTesting

Examples of com.google.common.collect.BstTesting.SimpleNode


    //    d
    //   / \
    //  b   f
    // /     \
    // a     g
    SimpleNode a = new SimpleNode('a', null, null);
    SimpleNode b = new SimpleNode('b', a, null);
    SimpleNode g = new SimpleNode('g', null, null);
    SimpleNode f = new SimpleNode('f', null, g);
    SimpleNode d = new SimpleNode('d', b, f);
    BstPathFactory<SimpleNode, BstInOrderPath<SimpleNode>> factory =
        BstInOrderPath.inOrderFactory();
    BstInOrderPath<SimpleNode> path = extension(factory, d, LEFT, LEFT);
    ASSERT.that(pathToList(path)).hasContentsInOrder(a, b, d);
    path = testNextPathIs(path, b, d);
View Full Code Here


    //    d
    //   / \
    //  b   f
    // /     \
    // a     g
    SimpleNode a = new SimpleNode('a', null, null);
    SimpleNode b = new SimpleNode('b', a, null);
    SimpleNode g = new SimpleNode('g', null, null);
    SimpleNode f = new SimpleNode('f', null, g);
    SimpleNode d = new SimpleNode('d', b, f);
    BstPathFactory<SimpleNode, BstInOrderPath<SimpleNode>> factory =
        BstInOrderPath.inOrderFactory();
    BstInOrderPath<SimpleNode> path = extension(factory, d, RIGHT, RIGHT);
    ASSERT.that(pathToList(path)).hasContentsInOrder(g, f, d);
    path = testPrevPathIs(path, f, d);
View Full Code Here

    //    d
    //   / \
    //  b   f
    //   \ /
    //   c e 
    SimpleNode c = new SimpleNode('c', null, null);
    SimpleNode b = new SimpleNode('b', null, c);
    SimpleNode e = new SimpleNode('e', null, null);
    SimpleNode f = new SimpleNode('f', e, null);
    SimpleNode d = new SimpleNode('d', b, f);
    BstPathFactory<SimpleNode, BstInOrderPath<SimpleNode>> factory =
        BstInOrderPath.inOrderFactory();
    BstInOrderPath<SimpleNode> path = extension(factory, d, LEFT);
    ASSERT.that(pathToList(path)).hasContentsInOrder(b, d);
    path = testNextPathIs(path, c, b, d);
View Full Code Here

    //    d
    //   / \
    //  b   f
    //   \ /
    //   c e 
    SimpleNode c = new SimpleNode('c', null, null);
    SimpleNode b = new SimpleNode('b', null, c);
    SimpleNode e = new SimpleNode('e', null, null);
    SimpleNode f = new SimpleNode('f', e, null);
    SimpleNode d = new SimpleNode('d', b, f);
    BstPathFactory<SimpleNode, BstInOrderPath<SimpleNode>> factory =
        BstInOrderPath.inOrderFactory();
    BstInOrderPath<SimpleNode> path = extension(factory, d, RIGHT);
    ASSERT.that(pathToList(path)).hasContentsInOrder(f, d);
    path = testPrevPathIs(path, e,f,d);
View Full Code Here

      super(tip, tail);
    }
  }

  public void testTailAtRoot() {
    SimpleNode root = new SimpleNode('a', null, null);
    SimplePath rootPath = new SimplePath(root, null);
    assertFalse(rootPath.hasPrefix());
    assertNull(rootPath.prefixOrNull());
    try {
      rootPath.getPrefix();
View Full Code Here

      fail("Expected IllegalStateException");
    } catch (IllegalStateException expected) {}
  }

  public void testTailDown() {
    SimpleNode node = new SimpleNode('a', null, null);
    SimpleNode root = new SimpleNode('b', node, null);
    SimplePath rootPath = new SimplePath(root, null);
    SimplePath nodePath = new SimplePath(node, rootPath);
    assertTrue(nodePath.hasPrefix());
    assertEquals(rootPath, nodePath.prefixOrNull());
    assertEquals(rootPath, nodePath.getPrefix());
View Full Code Here

@GwtCompatible
public abstract class AbstractBstBalancePolicyTest extends TestCase {
  protected abstract BstBalancePolicy<SimpleNode> getBalancePolicy();

  public void testBalanceLeaf() {
    SimpleNode a = new SimpleNode('a', null, null);
    assertInOrderTraversalIs(getBalancePolicy().balance(nodeFactory, a, null, null), "a");
  }
View Full Code Here

    SimpleNode a = new SimpleNode('a', null, null);
    assertInOrderTraversalIs(getBalancePolicy().balance(nodeFactory, a, null, null), "a");
  }

  private SimpleNode balanceNew(char c, @Nullable SimpleNode left, @Nullable SimpleNode right) {
    return getBalancePolicy().balance(nodeFactory, new SimpleNode(c, null, null), left, right);
  }
View Full Code Here

  public void testBalanceTree1() {
    //   b
    //    \
    //    c
    SimpleNode c = balanceNew('c', null, null);
    SimpleNode b = balanceNew('b', null, c);
    assertInOrderTraversalIs(b, "bc");
  }
View Full Code Here

  public void testBalanceTree2() {
    //   b
    //  /
    //  a
    SimpleNode a = balanceNew('a', null, null);
    SimpleNode b = balanceNew('b', a, null);
    assertInOrderTraversalIs(b, "ab");
  }
View Full Code Here

TOP

Related Classes of com.google.common.collect.BstTesting.SimpleNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.