Package com.google.common.collect.BstTesting

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


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


    //     \
    //     e
    //      \
    //       f

    SimpleNode f = balanceNew('f', null, null);
    SimpleNode e = balanceNew('e', null, f);
    SimpleNode d = balanceNew('d', null, e);
    SimpleNode c = balanceNew('c', null, d);
    SimpleNode b = balanceNew('b', null, c);
    SimpleNode a = balanceNew('a', null, b);
    assertInOrderTraversalIs(a, "abcdef");
  }
View Full Code Here

    //    c
    //   /
    //   b
    //  /
    //  a
    SimpleNode a = balanceNew('a', null, null);
    SimpleNode b = balanceNew('b', a, null);
    SimpleNode c = balanceNew('c', b, null);
    SimpleNode d = balanceNew('d', c, null);
    SimpleNode e = balanceNew('e', d, null);
    SimpleNode f = balanceNew('f', e, null);
    assertInOrderTraversalIs(f, "abcdef");
  }
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);
    assertEquals(a, BstOperations.seek(Ordering.natural(), d, 'a'));
    assertEquals(b, BstOperations.seek(Ordering.natural(), d, 'b'));
    assertNull(BstOperations.seek(Ordering.natural(), d, 'c'));
    assertEquals(d, BstOperations.seek(Ordering.natural(), d, 'd'));
    assertNull(BstOperations.seek(Ordering.natural(), d, 'e'));
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);
    assertNull(BstOperations.seek(Ordering.natural(), d, 'a'));
    assertEquals(b, BstOperations.seek(Ordering.natural(), d, 'b'));
    assertEquals(c, BstOperations.seek(Ordering.natural(), d, 'c'));
    assertEquals(d, BstOperations.seek(Ordering.natural(), d, 'd'));
    assertEquals(e, BstOperations.seek(Ordering.natural(), d, 'e'));
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);

    BstNodeFactory<SimpleNode> nodeFactory = EasyMock.createStrictMock(BstNodeFactory.class);
    BstBalancePolicy<SimpleNode> balancePolicy = EasyMock.createStrictMock(BstBalancePolicy.class);
    BstModifier<Character, SimpleNode> modifier = EasyMock.createStrictMock(BstModifier.class);

    SimpleNode c = new SimpleNode('c', null, null);
    expect(modifier.modify(eq('c'), (SimpleNode) isNull())).andReturn(
        BstModificationResult.rebalancingChange(null, c));

    expect(balancePolicy.balance(
        same(nodeFactory), same(c), (SimpleNode) isNull(), (SimpleNode) isNull()))
        .andReturn(c)
        .times(0, 1);

    SimpleNode bWithC = new SimpleNode('b', a, c);
    expectPossibleEntryfication(nodeFactory, b);
    expect(balancePolicy.balance(
        same(nodeFactory), withKey('b'), same(a), withKey('c')))
        .andReturn(bWithC);

    SimpleNode dWithBWithC = new SimpleNode('d', bWithC, f);
    expectPossibleEntryfication(nodeFactory, d);
    expect(
        balancePolicy.balance(same(nodeFactory), withKey('d'), same(bWithC), same(f)))
        .andReturn(dWithBWithC);
    replay(nodeFactory, balancePolicy, modifier);
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);

    BstNodeFactory<SimpleNode> nodeFactory = EasyMock.createStrictMock(BstNodeFactory.class);
    BstBalancePolicy<SimpleNode> balancePolicy = EasyMock.createStrictMock(BstBalancePolicy.class);
    BstModifier<Character, SimpleNode> modifier = EasyMock.createStrictMock(BstModifier.class);
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);

    BstNodeFactory<SimpleNode> nodeFactory = EasyMock.createStrictMock(BstNodeFactory.class);
    BstBalancePolicy<SimpleNode> balancePolicy = EasyMock.createStrictMock(BstBalancePolicy.class);
    BstModifier<Character, SimpleNode> modifier = EasyMock.createStrictMock(BstModifier.class);

    expectPossibleEntryfication(nodeFactory, a);
    SimpleNode a2 = new SimpleNode('a', null, null);
    expect(modifier.modify(eq('a'), withKey('a'))).andReturn(
        BstModificationResult.rebuildingChange(a, a2));

    expectPossibleEntryfication(nodeFactory, a2);

    SimpleNode bWithA2 = new SimpleNode('b', a2, null);
    expect(nodeFactory.createNode(same(b), withKey('a'), (SimpleNode) isNull())).andReturn(
        bWithA2);

    SimpleNode dWithA2 = new SimpleNode('d', bWithA2, f);
    expect(nodeFactory.createNode(same(d), same(bWithA2), same(f))).andReturn(
        dWithA2);

    replay(nodeFactory, balancePolicy, modifier);
    BstMutationRule<Character, SimpleNode> mutationRule =
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);

    BstNodeFactory<SimpleNode> nodeFactory = EasyMock.createStrictMock(BstNodeFactory.class);
    BstBalancePolicy<SimpleNode> balancePolicy = EasyMock.createStrictMock(BstBalancePolicy.class);
    BstModifier<Character, SimpleNode> modifier = EasyMock.createStrictMock(BstModifier.class);

    expectPossibleEntryfication(nodeFactory, a);
    expect(modifier.modify(eq('a'), withKey('a'))).andReturn(
        BstModificationResult.rebalancingChange(a, null));

    expect(balancePolicy.combine(same(nodeFactory), (SimpleNode) isNull(), (SimpleNode) isNull()))
        .andReturn(null);

    expectPossibleEntryfication(nodeFactory, b);
    SimpleNode leafB = new SimpleNode('b', null, null);
    expect(
        balancePolicy.balance(same(nodeFactory), withKey('b'), (SimpleNode) isNull(),
            (SimpleNode) isNull())).andReturn(leafB);

    SimpleNode dWithLeafB = new SimpleNode('d', leafB, f);
    expectPossibleEntryfication(nodeFactory, d);
    expect(
        balancePolicy.balance(same(nodeFactory), withKey('d'), same(leafB), same(f)))
        .andReturn(dWithLeafB);
    replay(nodeFactory, balancePolicy, modifier);
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);

    BstNodeFactory<SimpleNode> nodeFactory = EasyMock.createStrictMock(BstNodeFactory.class);
    BstBalancePolicy<SimpleNode> balancePolicy = EasyMock.createStrictMock(BstBalancePolicy.class);
    BstModifier<Character, SimpleNode> modifier = EasyMock.createStrictMock(BstModifier.class);
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.