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


Java TIntObjectMap.valueCollection方法代碼示例

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


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

示例1: testValueCollectionRetainAllCollection

import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRetainAllCollection() {
    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() );

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

    List<String> java_list = new ArrayList<String>();
    java_list.addAll( Arrays.asList( vals ) );
    assertFalse( "collection: " + collection + ", should contain all in list: " +
                 java_list, collection.retainAll( java_list ) );

    java_list.remove( 5 );
    assertTrue( "collection: " + collection + ", should contain all in list: " +
                java_list, collection.retainAll( java_list ) );
    assertFalse( collection.contains( vals[5] ) );
    assertFalse( map.containsKey( keys[5] ) );
    assertFalse( map.containsValue( vals[5] ) );
    assertTrue( "collection: " + collection + ", should contain all in list: " +
                java_list, collection.containsAll( java_list ) );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:34,代碼來源:TPrimitiveObjectHashMapTest.java

示例2: testValueCollectionRetainAllTCollection

import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRetainAllTCollection() {
    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() );

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

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

    Collection<String> other = new ArrayList<String>( 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] ) );
    assertTrue( "collection: " + collection + ", should contain all in other: " +
                other, collection.containsAll( other ) );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:36,代碼來源:TPrimitiveObjectHashMapTest.java

示例3: testValueCollectionRemoveAllCollection

import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRemoveAllCollection() {
    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() );

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

    List<String> java_list = new ArrayList<String>();
    assertFalse( "collection: " + collection + ", should contain all in list: " +
                 java_list, collection.removeAll( java_list ) );

    java_list.add( vals[5] );
    assertTrue( "collection: " + collection + ", should contain all in list: " +
                java_list, collection.removeAll( java_list ) );
    assertFalse( collection.contains( vals[5] ) );
    assertFalse( map.containsKey( keys[5] ) );
    assertFalse( map.containsValue( vals[5] ) );

    java_list = new ArrayList<String>();
    java_list.addAll( Arrays.asList( vals ) );
    assertTrue( "collection: " + collection + ", should contain all in list: " +
                java_list, collection.removeAll( java_list ) );
    assertTrue( collection.isEmpty() );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:37,代碼來源:TPrimitiveObjectHashMapTest.java

示例4: testValueCollectionContainsAll

import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionContainsAll() {
    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() );

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

    List<String> java_list = new ArrayList<String>();
    java_list.addAll( Arrays.asList( vals ) );
    assertTrue( "collection: " + collection + ", should contain all in list: " +
                java_list, collection.containsAll( java_list ) );
    java_list.add( String.valueOf( 1138 ) );
    assertFalse( "collection: " + collection + ", should not contain all in list: " +
                 java_list, collection.containsAll( java_list ) );

    List<CharSequence> number_list = new ArrayList<CharSequence>();
    for ( String value : vals ) {
        if ( value.equals( "5" ) ) {
            number_list.add( new StringBuilder().append( value ) );
        } else {
            number_list.add( String.valueOf( value ) );
        }
    }
    assertFalse( "collection: " + collection + ", should not contain all in list: " +
                 java_list, collection.containsAll( number_list ) );

    Collection<String> other = new ArrayList<String>( 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 ) );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:46,代碼來源:TPrimitiveObjectHashMapTest.java

示例5: testValueCollectionRemoveAllTCollection

import gnu.trove.map.TIntObjectMap; //導入方法依賴的package包/類
public void testValueCollectionRemoveAllTCollection() {
    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() );

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

    Collection<String> other = new ArrayList<String>();
    assertFalse( "collection: " + collection + ", should be unmodified.",
            collection.removeAll( other ) );

    other = new ArrayList<String>( 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 ) {
            assertTrue( collection.contains( vals[i] ) );
            assertTrue( map.containsKey( keys[i] ) );
            assertTrue( map.containsValue( vals[i] ) );
        } else {
            assertFalse( collection.contains( vals[i] ) );
            assertFalse( map.containsKey( keys[i] ) );
            assertFalse( map.containsValue( vals[i] ) );
        }
    }

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

    assertTrue( "collection: " + collection + ", should be modified. other: " +
                other, collection.removeAll( collection ) );
    assertTrue( collection.isEmpty() );
}
 
開發者ID:palantir,項目名稱:trove-3.0.3,代碼行數:48,代碼來源:TPrimitiveObjectHashMapTest.java


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