Reformat whole codebase using Android Studio
This commit is contained in:
parent
d5322667d5
commit
c15913c1ab
161 changed files with 15124 additions and 18537 deletions
|
|
@ -6,62 +6,54 @@ import java.util.HashMap;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CompactMapTest
|
||||
{
|
||||
public class CompactMapTest {
|
||||
@Test
|
||||
public void hashMapComparisonTest()
|
||||
{
|
||||
hashMapComparison( 0, 1 );
|
||||
hashMapComparison( 1, 1 );
|
||||
hashMapComparison( 2, 2 );
|
||||
hashMapComparison( 3, 3 );
|
||||
hashMapComparison( 4, 4 );
|
||||
hashMapComparison( 5, 5 );
|
||||
hashMapComparison( 7, 10 );
|
||||
hashMapComparison( 8, 10 );
|
||||
hashMapComparison( 10000, 20000 );
|
||||
public void hashMapComparisonTest() {
|
||||
hashMapComparison(0, 1);
|
||||
hashMapComparison(1, 1);
|
||||
hashMapComparison(2, 2);
|
||||
hashMapComparison(3, 3);
|
||||
hashMapComparison(4, 4);
|
||||
hashMapComparison(5, 5);
|
||||
hashMapComparison(7, 10);
|
||||
hashMapComparison(8, 10);
|
||||
hashMapComparison(10000, 20000);
|
||||
}
|
||||
|
||||
private void hashMapComparison( int mapsize, int trycount )
|
||||
{
|
||||
Random rand = new Random( 12345 );
|
||||
HashMap<Long,String> hmap = new HashMap<Long,String>();
|
||||
private void hashMapComparison(int mapsize, int trycount) {
|
||||
Random rand = new Random(12345);
|
||||
HashMap<Long, String> hmap = new HashMap<Long, String>();
|
||||
CompactLongMap<String> cmap_slow = new CompactLongMap<String>();
|
||||
CompactLongMap<String> cmap_fast = new CompactLongMap<String>();
|
||||
|
||||
for( int i=0; i<mapsize; i++ )
|
||||
{
|
||||
for (int i = 0; i < mapsize; i++) {
|
||||
String s = "" + i;
|
||||
long k = mapsize < 10 ? i : rand.nextInt( 20000 );
|
||||
Long KK = new Long( k );
|
||||
long k = mapsize < 10 ? i : rand.nextInt(20000);
|
||||
Long KK = new Long(k);
|
||||
|
||||
if ( !hmap.containsKey( KK ) )
|
||||
{
|
||||
hmap.put( KK, s );
|
||||
cmap_slow.put( k, s );
|
||||
cmap_fast.fastPut( k, s );
|
||||
if (!hmap.containsKey(KK)) {
|
||||
hmap.put(KK, s);
|
||||
cmap_slow.put(k, s);
|
||||
cmap_fast.fastPut(k, s);
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=0; i<trycount*2; i++ )
|
||||
{
|
||||
if ( i == trycount )
|
||||
{
|
||||
cmap_slow = new FrozenLongMap<String>( cmap_slow );
|
||||
cmap_fast = new FrozenLongMap<String>( cmap_fast );
|
||||
for (int i = 0; i < trycount * 2; i++) {
|
||||
if (i == trycount) {
|
||||
cmap_slow = new FrozenLongMap<String>(cmap_slow);
|
||||
cmap_fast = new FrozenLongMap<String>(cmap_fast);
|
||||
}
|
||||
long k = mapsize < 10 ? i : rand.nextInt( 20000 );
|
||||
Long KK = new Long( k );
|
||||
String s = hmap.get( KK );
|
||||
long k = mapsize < 10 ? i : rand.nextInt(20000);
|
||||
Long KK = new Long(k);
|
||||
String s = hmap.get(KK);
|
||||
|
||||
boolean contained = hmap.containsKey( KK );
|
||||
Assert.assertTrue( "containsKey missmatch (slow)", contained == cmap_slow.contains( k ) );
|
||||
Assert.assertTrue( "containsKey missmatch (fast)", contained == cmap_fast.contains( k ) );
|
||||
|
||||
if ( contained )
|
||||
{
|
||||
Assert.assertEquals( "object missmatch (fast)", s, cmap_fast.get( k ) );
|
||||
Assert.assertEquals( "object missmatch (slow)", s, cmap_slow.get( k ) );
|
||||
boolean contained = hmap.containsKey(KK);
|
||||
Assert.assertTrue("containsKey missmatch (slow)", contained == cmap_slow.contains(k));
|
||||
Assert.assertTrue("containsKey missmatch (fast)", contained == cmap_fast.contains(k));
|
||||
|
||||
if (contained) {
|
||||
Assert.assertEquals("object missmatch (fast)", s, cmap_fast.get(k));
|
||||
Assert.assertEquals("object missmatch (slow)", s, cmap_slow.get(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue