當前位置: 首頁>>代碼示例>>Java>>正文


Java TIntSet.toArray方法代碼示例

本文整理匯總了Java中gnu.trove.set.TIntSet.toArray方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntSet.toArray方法的具體用法?Java TIntSet.toArray怎麽用?Java TIntSet.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在gnu.trove.set.TIntSet的用法示例。


在下文中一共展示了TIntSet.toArray方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testToArrayMatchesIteratorOrder

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testToArrayMatchesIteratorOrder() {
    TIntSet set = new TIntOffheapHashSet();
    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;
    while (iter.hasNext()) {
        iter_ints[index++] = iter.next();
    }

    assertTrue(Arrays.equals(iter_ints, toarray_ints));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:17,代碼來源:TPrimitiveOffheapHashSetTest.java

示例2: testToArrayMatchesIteratorOrder

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
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;
    while (iter.hasNext()) {
        iter_ints[index++] = iter.next();
    }

    assertTrue(Arrays.equals(iter_ints, toarray_ints));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:17,代碼來源:TPrimitiveHashSetTest.java

示例3: testToArraySmallerInput

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testToArraySmallerInput() {
       TIntSet set = new TIntHashSet();
       int[] ints = {42, 1138, 13, 86, 99};
       set.addAll(ints);


	int[] input = new int[ 3 ];
	int[] result = set.toArray( input );

	assertNotSame( input, result );
	assertEquals( 5, result.length );
	Arrays.sort( result );
	assertEquals( result[ 0 ], 13 );
	assertEquals( result[ 1 ], 42 );
	assertEquals( result[ 2 ], 86 );
	assertEquals( result[ 3 ], 99 );
	assertEquals( result[ 4 ], 1138 );
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:19,代碼來源:TPrimitiveHashSetTest.java

示例4: testToArray

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testToArray() {
    TIntSet set = new TIntOffheapHashSet();
    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));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:10,代碼來源:TPrimitiveOffheapHashSetTest.java

示例5: testToArray

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
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));
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:10,代碼來源:TPrimitiveHashSetTest.java

示例6: testKeySetMisc

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetMisc() {
    int[] keys = {1138, 42, 86, 99, 101, 727, 117};
    long[] vals = new long[keys.length];

    TIntLongMap map = new TIntLongHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }

    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 ) );

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

    assertFalse( "remove of element not in set succeded: " + set, set.remove( 1 ) );
    assertEquals( keys.length, set.size() );
    assertEquals( keys.length, map.size() );

    assertTrue( "remove of element in set failed: " + set, set.remove( 42 ) );
    assertEquals( keys.length - 1, set.size() );
    assertEquals( keys.length - 1, map.size() );

    try {
        set.add( 42 );
        fail( "Expected UnsupportedOperationException" );
    }
    catch ( UnsupportedOperationException ex ) {
        // Expected
    }
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:43,代碼來源:TPrimitivePrimitiveHashMapTest.java

示例7: testKeySetMisc

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetMisc() {
    int[] keys = {1138, 42, 86, 99, 101, 727, 117};
    long[] vals = new long[keys.length];

    TIntLongMap map = new TIntLongOffheapHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }

    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 ) );

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

    assertFalse( "remove of element not in set succeded: " + set, set.remove( 1 ) );
    assertEquals( keys.length, set.size() );
    assertEquals( keys.length, map.size() );

    assertTrue( "remove of element in set failed: " + set, set.remove( 42 ) );
    assertEquals( keys.length - 1, set.size() );
    assertEquals( keys.length - 1, map.size() );

    try {
        set.add( 42 );
        fail( "Expected UnsupportedOperationException" );
    }
    catch ( UnsupportedOperationException ex ) {
        // Expected
    }
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:43,代碼來源:TPrimitivePrimitiveOffheapHashMapTest.java


注:本文中的gnu.trove.set.TIntSet.toArray方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。