Package gnu.trove.set

Examples of gnu.trove.set.TIntSet.toArray()


        TIntSet set = map.keySet();
        int[] sorted_keys = new int[ keys.length ];
        System.arraycopy( keys, 0, sorted_keys, 0, keys.length );
        Arrays.sort( sorted_keys );
        int[] setarray = set.toArray();
        Arrays.sort( setarray );
        assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
                    ", was: " + Arrays.toString( setarray ),
                Arrays.equals( sorted_keys, setarray ) );
View Full Code Here


        Arrays.sort( setarray );
        assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
                    ", was: " + Arrays.toString( setarray ),
                Arrays.equals( sorted_keys, setarray ) );

        setarray = set.toArray( new int[0] );
        Arrays.sort( setarray );
        assertTrue( "expected: " + Arrays.toString( sorted_keys ) +
                    ", was: " + Arrays.toString( setarray ),
                Arrays.equals( sorted_keys, setarray ) );
View Full Code Here

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

        int[] keys_array = keyset.toArray();
        int count = 0;
        TIntIterator iter = keyset.iterator();
        while ( iter.hasNext() ) {
            int key = iter.next();
            assertTrue( keyset.contains( key ) );
View Full Code Here

            assertEquals( keys_array[count], key );
            count++;
        }

        //noinspection ToArrayCallWithZeroLengthArrayArgument
        keys_array = keyset.toArray( new int[0] );
        count = 0;
        iter = keyset.iterator();
        while ( iter.hasNext() ) {
            int key = iter.next();
            assertTrue( keyset.contains( key ) );
View Full Code Here

            assertTrue( keyset.contains( key ) );
            assertEquals( keys_array[count], key );
            count++;
        }

        keys_array = keyset.toArray( new int[keyset.size()] );
        count = 0;
        iter = keyset.iterator();
        while ( iter.hasNext() ) {
            int key = iter.next();
            assertTrue( keyset.contains( key ) );
View Full Code Here

            assertTrue( keyset.contains( key ) );
            assertEquals( keys_array[count], key );
            count++;
        }

        keys_array = keyset.toArray( new int[keyset.size() * 2] );
        count = 0;
        iter = keyset.iterator();
        while ( iter.hasNext() ) {
            int key = iter.next();
            assertTrue( keyset.contains( key ) );
View Full Code Here

    public void testToArray() {
        TIntSet set = new TIntHashSet();
        int[] ints = {42, 1138, 13, 86, 99};
        set.addAll( ints );
        int[] res = set.toArray();
        Arrays.sort( ints );
        Arrays.sort( res );
        assertTrue( Arrays.equals( ints, res ) );
    }
View Full Code Here

    public void testToArrayMatchesIteratorOrder() {
        TIntSet set = new TIntHashSet();
        int[] ints = {42, 1138, 13, 86, 99};
        set.addAll( ints );
        int[] toarray_ints = set.toArray();

        int[] iter_ints = new int[5];
        TIntIterator iter = set.iterator();

        int index = 0;
View Full Code Here

        int[] sink = new int[ints.length + 2];
        sink[sink.length - 1] = -1;
        sink[sink.length - 2] = -2;

        int[] res = set.toArray( sink );
        assertEquals( set.getNoEntryValue(), res[set.size()] );

        Set<Integer> copy = new HashSet<Integer>();
        for ( int element : sink ) {
            copy.add( Integer.valueOf( element ) );
View Full Code Here

    public void testToArray() {
        TIntSet set = new TIntHashSet();
        int[] ints = {42, 1138, 13, 86, 99};
        set.addAll(ints);
        int[] res = set.toArray();
        Arrays.sort(ints);
        Arrays.sort(res);
        assertTrue(Arrays.equals(ints, res));
    }
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.