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,55 +6,48 @@ import java.util.HashSet;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CompactSetTest
|
||||
{
|
||||
public class CompactSetTest {
|
||||
@Test
|
||||
public void hashSetComparisonTest()
|
||||
{
|
||||
hashSetComparison( 0, 1 );
|
||||
hashSetComparison( 1, 1 );
|
||||
hashSetComparison( 2, 2 );
|
||||
hashSetComparison( 3, 3 );
|
||||
hashSetComparison( 4, 4 );
|
||||
hashSetComparison( 5, 5 );
|
||||
hashSetComparison( 7, 10 );
|
||||
hashSetComparison( 8, 10 );
|
||||
hashSetComparison( 10000, 20000 );
|
||||
public void hashSetComparisonTest() {
|
||||
hashSetComparison(0, 1);
|
||||
hashSetComparison(1, 1);
|
||||
hashSetComparison(2, 2);
|
||||
hashSetComparison(3, 3);
|
||||
hashSetComparison(4, 4);
|
||||
hashSetComparison(5, 5);
|
||||
hashSetComparison(7, 10);
|
||||
hashSetComparison(8, 10);
|
||||
hashSetComparison(10000, 20000);
|
||||
}
|
||||
|
||||
private void hashSetComparison( int setsize, int trycount )
|
||||
{
|
||||
Random rand = new Random( 12345 );
|
||||
private void hashSetComparison(int setsize, int trycount) {
|
||||
Random rand = new Random(12345);
|
||||
HashSet<Long> hset = new HashSet<Long>();
|
||||
CompactLongSet cset_slow = new CompactLongSet();
|
||||
CompactLongSet cset_fast = new CompactLongSet();
|
||||
|
||||
for( int i=0; i<setsize; i++ )
|
||||
{
|
||||
long k = setsize < 10 ? i : rand.nextInt( 20000 );
|
||||
Long KK = new Long( k );
|
||||
for (int i = 0; i < setsize; i++) {
|
||||
long k = setsize < 10 ? i : rand.nextInt(20000);
|
||||
Long KK = new Long(k);
|
||||
|
||||
if ( !hset.contains( KK ) )
|
||||
{
|
||||
hset.add( KK );
|
||||
cset_slow.add( k );
|
||||
cset_fast.fastAdd( k );
|
||||
if (!hset.contains(KK)) {
|
||||
hset.add(KK);
|
||||
cset_slow.add(k);
|
||||
cset_fast.fastAdd(k);
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=0; i<trycount*2; i++ )
|
||||
{
|
||||
if ( i == trycount )
|
||||
{
|
||||
cset_slow = new FrozenLongSet( cset_slow );
|
||||
cset_fast = new FrozenLongSet( cset_fast );
|
||||
for (int i = 0; i < trycount * 2; i++) {
|
||||
if (i == trycount) {
|
||||
cset_slow = new FrozenLongSet(cset_slow);
|
||||
cset_fast = new FrozenLongSet(cset_fast);
|
||||
}
|
||||
long k = setsize < 10 ? i : rand.nextInt( 20000 );
|
||||
Long KK = new Long( k );
|
||||
long k = setsize < 10 ? i : rand.nextInt(20000);
|
||||
Long KK = new Long(k);
|
||||
|
||||
boolean contained = hset.contains( KK );
|
||||
Assert.assertTrue( "contains missmatch (slow)", contained == cset_slow.contains( k ) );
|
||||
Assert.assertTrue( "contains missmatch (fast)", contained == cset_fast.contains( k ) );
|
||||
boolean contained = hset.contains(KK);
|
||||
Assert.assertTrue("contains missmatch (slow)", contained == cset_slow.contains(k));
|
||||
Assert.assertTrue("contains missmatch (fast)", contained == cset_fast.contains(k));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue