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 ) ); }
@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); }
@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); }
@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(); }
@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(); }