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


Java TIntSet.retainAll方法代碼示例

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


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

示例1: testKeySetRetainAllCollection

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetRetainAllCollection() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

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

    Collection<Integer> test_collection = new HashSet<Integer>();
    for ( int i = 0; i < element_count; i++ ) {
        test_collection.add( keys[i] );
    }
    keyset.retainAll( test_collection );
    assertFalse( keyset.isEmpty() );
    assertFalse( map.isEmpty() );

    // Reset map
    for ( int i = 0; i < element_count; i++ ) {
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

    test_collection.remove( Integer.valueOf( keys[5] ) );
    keyset.retainAll( test_collection );
    assertEquals( element_count - 1, keyset.size() );
    assertEquals( element_count - 1, map.size() );
    assertFalse( keyset.contains( keys[5] ) );
    assertFalse( map.containsKey( keys[5] ) );


    // Reset map
    for ( int i = 0; i < element_count; i++ ) {
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

    test_collection.add( Integer.valueOf( 1138 ) );
    keyset.retainAll( test_collection );

}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:52,代碼來源:TPrimitiveObjectHashMapTest.java

示例2: testKeySetRetainAllCollection

import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetRetainAllCollection() {
    int element_count = 20;
    int[] keys = new int[element_count];
    String[] vals = new String[element_count];

    TIntObjectMap<String> map = new TIntObjectHashMap<String>();
    for ( int i = 0; i < element_count; i++ ) {
        keys[i] = i + 1;
        vals[i] = Integer.toString( i + 1 );
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

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

    Collection<Integer> test_collection = new HashSet<Integer>();
    for ( int i = 0; i < element_count; i++ ) {
        test_collection.add( keys[i] );
    }
    keyset.retainAll( test_collection );
    assertFalse( keyset.isEmpty() );
    assertFalse( map.isEmpty() );

    // Reset map
    for ( int i = 0; i < element_count; i++ ) {
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

    test_collection.remove( Integer.valueOf( keys[5] ) );
    keyset.retainAll( test_collection );
    assertEquals( element_count - 1, keyset.size() );
    assertEquals( element_count - 1, map.size() );
    assertFalse( keyset.contains( keys[5] ) );
    assertFalse( map.containsKey( keys[5] ) );
    

    // Reset map
    for ( int i = 0; i < element_count; i++ ) {
        map.put( keys[i], vals[i] );
    }
    assertEquals( element_count, map.size() );

    test_collection.add( Integer.valueOf( 1138 ) );
    keyset.retainAll( test_collection );
    
}
 
開發者ID:leventov,項目名稱:trove-over-koloboke-compile,代碼行數:52,代碼來源:TPrimitiveObjectHashMapTest.java


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