Package gnu.trove.list.array

Examples of gnu.trove.list.array.TIntArrayList


        assertFalse( keyset.isEmpty() );

        assertFalse( "keyset: " + keyset + ", should be unmodified.",
                keyset.retainAll( keyset ) );

        TIntCollection other = new TIntArrayList( keyset );
        assertFalse( "keyset: " + keyset + ", should be unmodified. other: " +
                     other, keyset.retainAll( other ) );

        other.remove( keys[5] );
        assertTrue( "keyset: " + keyset + ", should be modified. other: " +
                    other, keyset.retainAll( other ) );
        assertFalse( keyset.contains( keys[5] ) );
        assertFalse( map.containsKey( keys[5] ) );
        assertFalse( map.containsValue( vals[5] ) );
View Full Code Here


        for ( int i = 0; i < keyset.size(); i++ ) {
            assertTrue( keyset.contains( keys[i] ) );
        }
        assertFalse( keyset.isEmpty() );

        TIntCollection other = new TIntArrayList();
        assertFalse( "collection: " + keyset + ", should be unmodified.",
                keyset.removeAll( other ) );

        other = new TIntArrayList( keyset );
        other.remove( keys[5] );
        assertTrue( "collection: " + keyset + ", should be modified. other: " +
                    other, keyset.removeAll( other ) );
        assertEquals( 1, keyset.size() );
        for ( int i = 0; i < element_count; i++ ) {
            if ( i == 5 ) {
View Full Code Here

        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

        }
        assertEquals( element_count, map.size() );

        class ForEach implements TIntProcedure {

            TIntList built = new TIntArrayList();


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


            TIntList getBuilt() {
                return built;
            }
        }

        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

            count++;
        }
        assertEquals( collection.getNoEntryValue(), values_array[collection.size()] );
        assertEquals( map.getNoEntryValue(), values_array[collection.size()] );

        TIntCollection other = new TIntArrayList( collection );
        assertFalse( collection.retainAll( other ) );
        other.remove( vals[5] );
        assertTrue( collection.retainAll( other ) );
        assertFalse( collection.contains( vals[5] ) );
        assertFalse( map.containsKey( keys[5] ) );

        collection.clear();
View Full Code Here

        catch ( UnsupportedOperationException ex ) {
            // Expected
        }

        try {
            TIntCollection test = new TIntArrayList();
            test.add( 1138 );
            collection.addAll( test );
            fail( "Expected UnsupportedOperationException" );
        }
        catch ( UnsupportedOperationException ex ) {
            // Expected
View Full Code Here

            }
        }
        assertFalse( "collection: " + collection + ", should not contain all in list: " +
                     java_list, collection.containsAll( number_list ) );

        TIntCollection other = new TIntArrayList( collection );
        assertTrue( "collection: " + collection + ", should contain all in other: " +
                    other, collection.containsAll( other ) );
        other.add( 1138 );
        assertFalse( "collection: " + collection + ", should not contain all in other: " +
                     other, collection.containsAll( other ) );

        assertTrue( "collection: " + collection + ", should contain all in array: " +
                    Arrays.toString( vals ), collection.containsAll( vals ) );
View Full Code Here

        assertFalse( collection.isEmpty() );

        assertFalse( "collection: " + collection + ", should be unmodified.",
                collection.retainAll( collection ) );

        TIntCollection other = new TIntArrayList( collection );
        assertFalse( "collection: " + collection + ", should be unmodified. other: " +
                     other, collection.retainAll( other ) );

        other.remove( vals[5] );
        assertTrue( "collection: " + collection + ", should be modified. other: " +
                    other, collection.retainAll( other ) );
        assertFalse( collection.contains( vals[5] ) );
        assertFalse( map.containsKey( keys[5] ) );
        assertFalse( map.containsValue( vals[5] ) );
View Full Code Here

        for ( int i = 0; i < collection.size(); i++ ) {
            assertTrue( collection.contains( vals[i] ) );
        }
        assertFalse( collection.isEmpty() );

        TIntCollection other = new TIntArrayList();
        assertFalse( "collection: " + collection + ", should be unmodified.",
                collection.removeAll( other ) );

        other = new TIntArrayList( collection );
        other.remove( vals[5] );
        assertTrue( "collection: " + collection + ", should be modified. other: " +
                    other, collection.removeAll( other ) );
        assertEquals( 1, collection.size() );
        for ( int i = 0; i < element_count; i++ ) {
            if ( i == 5 ) {
View Full Code Here

        assertEquals( element_count, map.size() );

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

        // Zero length array
        values_array = map.values( new int[0] );
        assertEquals( element_count, values_array.length );
        values_list = new TIntArrayList( values_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( values_list.contains( vals[i] ) );
        }

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

        // longer array
        values_array = map.values( new int[element_count * 2] );
        assertEquals( element_count * 2, values_array.length );
        values_list = new TIntArrayList( values_array );
        for ( int i = 0; i < element_count; i++ ) {
            assertTrue( values_list.contains( vals[i] ) );
        }
        assertEquals( map.getNoEntryValue(), values_array[element_count] );
    }
View Full Code Here

TOP

Related Classes of gnu.trove.list.array.TIntArrayList

Copyright © 2018 www.massapicom. 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.