Examples of TIntList


Examples of gnu.trove.list.TIntList

    boolean propagate() {
        boolean result = true;
        while (qhead_ < trail_.size()) {
            int p = trail_.get(qhead_++);
            // Propagate the implies first.
            TIntList to_add = implies_.get(p);
            if (to_add != null) {
                for (int i = 0; i < to_add.size(); ++i) {
                    if (!enqueue(to_add.get(i))) {
                        return false;
                    }
                }
            }
View Full Code Here

Examples of gnu.trove.list.TIntList

        assertEquals( element_count, map.size() );

        // No argument
        int[] keys_array = map.keys();
        assertEquals( element_count, keys_array.length );
        TIntList keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }

        // Zero length array
        keys_array = map.keys( new int[0] );
        assertEquals( element_count, keys_array.length );
        keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }

        // appropriate length array
        keys_array = map.keys( new int[map.size()] );
        assertEquals( element_count, keys_array.length );
        keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }

        // longer array
        keys_array = map.keys( new int[element_count * 2] );
        assertEquals( element_count * 2, keys_array.length );
        keys_list = new TIntArrayList( keys_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( keys_list.contains( keys[i] ) );
        }
        assertEquals( map.getNoEntryKey(), keys_array[element_count] );
    }
View Full Code Here

Examples of gnu.trove.list.TIntList

            }
        }

        ForEach foreach = new ForEach();
        map.forEachKey( foreach );
        TIntList built = foreach.getBuilt();
        TIntList keys_list = new TIntArrayList( map.keys( new int[map.size()] ) );
        assertEquals( keys_list, built );

        built.sort();
        keys_list.sort();
        assertEquals( keys_list, built );


        class ForEachFalse implements TIntProcedure {

            TIntList built = new TIntArrayList();


            public boolean execute( int value ) {
                built.add( value );
                return false;
            }


            TIntList getBuilt() {
                return built;
            }
        }

        ForEachFalse foreach_false = new ForEachFalse();
        map.forEachKey( foreach_false );
        built = foreach_false.getBuilt();
        keys_list = new TIntArrayList( map.keys( new int[map.size()] ) );
        assertEquals( 1, built.size() );
        assertEquals( keys_list.get( 0 ), built.get( 0 ) );
    }
View Full Code Here

Examples of gnu.trove.list.TIntList

        assertEquals(0, list.sum());
    }

    public void testBinarySearch() {
        System.out.println("Java version: " + System.getProperty("java.version"));
        TIntList list;
        for (int i = 0; i <= 100000; i++) {
            if ((i % 100) == 0) {
                System.out.print(i);
                System.out.print(" ");
            }

            list = new TIntArrayList(i);
            list.add(5);
            list.binarySearch(6);
        }

        list = new TIntArrayList();
        list.add(5);

        assertEquals(-1, list.binarySearch(Integer.MIN_VALUE));
        assertEquals(-1, list.binarySearch(-1));
        assertEquals(-1, list.binarySearch(0));
        assertEquals(-1, list.binarySearch(1));
        assertEquals(-1, list.binarySearch(2));
        assertEquals(-1, list.binarySearch(3));
        assertEquals(-1, list.binarySearch(4));

        assertEquals(0, list.binarySearch(5));

        assertEquals(-2, list.binarySearch(6));
    }
View Full Code Here

Examples of gnu.trove.list.TIntList

        int[] a = new int[]{1, 2, 3};
        i.retainAll(a);
    }

  public void testIntUnmodifiableEquality() {
    TIntList list1 = new TIntArrayList();
    TIntList list2 = new TIntArrayList();

    assertEquals( list1, list2 );
    assertEquals( list1, TCollections.unmodifiableList( list2 ) );
    assertEquals( TCollections.unmodifiableList( list1 ), list2 );
    assertEquals( TCollections.unmodifiableList( list1 ),
      TCollections.unmodifiableList( list2 ) );

    list1.add( 1 );
    list1.add( 2 );
    list1.add( 3 );

    list2.add( 1 );
    list2.add( 2 );
    list2.add( 3 );

    assertEquals( list1, list2 );
    assertEquals( list1, TCollections.unmodifiableList( list2 ) );
    assertEquals( TCollections.unmodifiableList( list1 ), list2 );
    assertEquals( TCollections.unmodifiableList( list1 ),
View Full Code Here

Examples of gnu.trove.list.TIntList

    it.set( slot3 );
  }

  public void testBinarySearch() {
    System.out.println( "Java version: " + System.getProperty( "java.version" ) );
    TIntList list;

    // Uncomment to stress test
//    for( int i = 0; i <= 100000; i++ ) {
//      if ( ( i % 100 ) == 0 ) {
//        System.out.print( i );
//        System.out.print( " " );
//      }
//
//      list = new TIntArrayList( i );
//      list.add( 5 );
//      list.binarySearch( 6 );
//    }

    list = new TIntLinkedList();
    list.add( 5 );

    // Uncomment this to see infinite loop from bug 3379877
//    list.binarySearch( 6 );

    assertEquals( -1, list.binarySearch( Integer.MIN_VALUE ) );
    assertEquals( -1, list.binarySearch( -1 ) );
    assertEquals( -1, list.binarySearch( 0 ) );
    assertEquals( -1, list.binarySearch( 1 ) );
    assertEquals( -1, list.binarySearch( 2 ) );
    assertEquals( -1, list.binarySearch( 3 ) );
    assertEquals( -1, list.binarySearch( 4 ) );

    assertEquals( 0, list.binarySearch( 5 ) );

    assertEquals( -2, list.binarySearch( 6 ) );
  }
View Full Code Here

Examples of gnu.trove.list.TIntList

    assertEquals( -2, list.binarySearch( 6 ) );
  }


  public void testSum() {
    TIntList list = new TIntLinkedList();
    assertEquals( 0, list.sum() );

    list.add( 1 );
    assertEquals( 1, list.sum() );

    list.add( 1234 );
    assertEquals( 1235, list.sum() );

    list.removeAt( 0 );
    assertEquals( 1234, list.sum() );

    list.clear();
    assertEquals( 0, list.sum() );
  }
View Full Code Here

Examples of gnu.trove.list.TIntList

    assertEquals( list.indexOf( 2 ), 2 );
    assertEquals( list.indexOf( 3 ), 3 );
  }

  public void testIntUnmodifiableEquality() {
    TIntList list1 = new TIntLinkedList();
    TIntList list2 = new TIntLinkedList();

    assertEquals( list1, list2 );
    assertEquals( list1, TCollections.unmodifiableList( list2 ) );
    assertEquals( TCollections.unmodifiableList( list1 ), list2 );
    assertEquals( TCollections.unmodifiableList( list1 ),
      TCollections.unmodifiableList( list2 ) );

    list1.add( 1 );
    list1.add( 2 );
    list1.add( 3 );

    list2.add( 1 );
    list2.add( 2 );
    list2.add( 3 );

    assertEquals( list1, list2 );
    assertEquals( list1, TCollections.unmodifiableList( list2 ) );
    assertEquals( TCollections.unmodifiableList( list1 ), list2 );
    assertEquals( TCollections.unmodifiableList( list1 ),
View Full Code Here

Examples of gnu.trove.list.TIntList

*/
public class TCollectionsTest extends TestCase {
  public void testUnmodifiableList() {
    final TIntArrayList one = new TIntArrayList( new int[]{ 1, 2, 3, 4 } );
    final TIntArrayList two = new TIntArrayList( new int[]{ 1, 2, 3, 4 } );
    TIntList uOne = TCollections.unmodifiableList( one );
    TIntList uTwo = TCollections.unmodifiableList( two );

    assertEquals( one, two );
    assertEquals( uOne, uTwo );

  }
View Full Code Here

Examples of gnu.trove.list.TIntList

        assertEquals(2, array_too_short[1]);
    }


    public void testSubList() throws Exception {
        TIntList subList = list.subList(1, 4);
        assertEquals(3, subList.size());
        assertEquals(2, subList.get(0));
        assertEquals(4, subList.get(2));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.