Java 类gnu.trove.map.hash.TCustomHashMap 实例源码

项目:trove-3.0.3    文件:IdentityHashingStrategyTest.java   
public void testInMap() {
    Map<Integer,String> map =
        new TCustomHashMap<Integer, String>( new IdentityHashingStrategy<Integer>() );

    Integer first = new Integer( 0 );
    Integer second = new Integer( 0 );

    map.put( first, "first" );

    assertEquals( 1, map.size() );
    assertTrue( map.containsKey( first ));
    assertFalse( map.containsKey( second ) );
    assertEquals( "first", map.get( first ) );

    map.put( second, "second" );

    assertEquals( 2, map.size() );
    assertEquals( "first", map.get( first ) );
    assertEquals( "second", map.get( second ) );

    map.remove( first );

    assertEquals( 1, map.size() );
    assertFalse( map.containsKey( first ) );
    assertTrue( map.containsKey( second ) );
}
项目:trove-over-koloboke-compile    文件:IdentityHashingStrategyTest.java   
public void testInMap() {
    Map<Integer,String> map =
        new TCustomHashMap<Integer, String>( new IdentityHashingStrategy<Integer>() );

    Integer first = new Integer( 0 );
    Integer second = new Integer( 0 );

    map.put( first, "first" );

    assertEquals( 1, map.size() );
    assertTrue( map.containsKey( first ));
    assertFalse( map.containsKey( second ) );
    assertEquals( "first", map.get( first ) );

    map.put( second, "second" );

    assertEquals( 2, map.size() );
    assertEquals( "first", map.get( first ) );
    assertEquals( "second", map.get( second ) );

    map.remove( first );

    assertEquals( 1, map.size() );
    assertFalse( map.containsKey( first ) );
    assertTrue( map.containsKey( second ) );
}
项目:gnu.trove    文件:IdentityHashingStrategyTest.java   
public void testInMap() {
    Map<Integer,String> map =
        new TCustomHashMap<Integer, String>( new IdentityHashingStrategy<Integer>() );

    Integer first = new Integer( 0 );
    Integer second = new Integer( 0 );

    map.put( first, "first" );

    assertEquals( 1, map.size() );
    assertTrue( map.containsKey( first ));
    assertFalse( map.containsKey( second ) );
    assertEquals( "first", map.get( first ) );

    map.put( second, "second" );

    assertEquals( 2, map.size() );
    assertEquals( "first", map.get( first ) );
    assertEquals( "second", map.get( second ) );

    map.remove( first );

    assertEquals( 1, map.size() );
    assertFalse( map.containsKey( first ) );
    assertTrue( map.containsKey( second ) );
}
项目:trove    文件:IdentityHashingStrategyTest.java   
public void testInMap() {
    Map<Integer,String> map =
        new TCustomHashMap<Integer, String>( new IdentityHashingStrategy<Integer>() );

    Integer first = new Integer( 0 );
    Integer second = new Integer( 0 );

    map.put( first, "first" );

    assertEquals( 1, map.size() );
    assertTrue( map.containsKey( first ));
    assertFalse( map.containsKey( second ) );
    assertEquals( "first", map.get( first ) );

    map.put( second, "second" );

    assertEquals( 2, map.size() );
    assertEquals( "first", map.get( first ) );
    assertEquals( "second", map.get( second ) );

    map.remove( first );

    assertEquals( 1, map.size() );
    assertFalse( map.containsKey( first ) );
    assertTrue( map.containsKey( second ) );
}
项目:mutinack    文件:TestPolymorphicTCustomCost.java   
@Setup
public void setup() {
    mapMono = new THashMap0<>(1, loadFactor);
    fill(mapMono);
    mapPoly = new THashMap<>(1, loadFactor);
    fill(mapPoly);
    customMapPoly = new TCustomHashMap<>(strategy, 1, loadFactor);
    fill(customMapPoly);
}
项目:hashmapTest    文件:TroveIdentityMapTest.java   
@Override
public void setup(final int[] keys, final float fillFactor, final int oneFailureOutOf ) {
    super.setup( keys, fillFactor, oneFailureOutOf );
    m_map = new TCustomHashMap<>( IdentityHashingStrategy.INSTANCE, keys.length, fillFactor );
    for (Integer key : m_keys)
        m_map.put(key % oneFailureOutOf == 0 ? key + 1 : key, key);
}
项目:hashmapTest    文件:TroveIdentityMapTest.java   
@Override
public int test() {
    final Map<Integer, Integer> m_map = new TCustomHashMap<>( IdentityHashingStrategy.INSTANCE, m_keys.length, m_fillFactor );
    for ( int i = 0; i < m_keys.length; ++i )
       m_map.put( m_keys[ i ], m_keys[ i ] );
    for ( int i = 0; i < m_keys.length; ++i ) //same key set is used for identity tests
       m_map.put( m_keys[ i ], m_keys[ i ] );
    return m_map.size();
}
项目:hashmapTest    文件:TroveIdentityMapTest.java   
@Override
public int test() {
    final Map<Integer, Integer> m_map = new TCustomHashMap<>( IdentityHashingStrategy.INSTANCE, m_keys.length / 2 + 1, m_fillFactor );
    int add = 0, remove = 0;
    while ( add < m_keys.length )
    {
        m_map.put( m_keys[ add ], m_keys[ add ] );
        ++add;
        m_map.put( m_keys[ add ], m_keys[ add ] );
        ++add;
        m_map.remove( m_keys[ remove++ ] );
    }
    return m_map.size();
}