当前位置: 首页>>代码示例>>Java>>正文


Java TIntLongMap.keySet方法代码示例

本文整理汇总了Java中gnu.trove.map.TIntLongMap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java TIntLongMap.keySet方法的具体用法?Java TIntLongMap.keySet怎么用?Java TIntLongMap.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.map.TIntLongMap的用法示例。


在下文中一共展示了TIntLongMap.keySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testKeySetRemoveAllArray

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRemoveAllArray() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test raw array
    map = new TIntLongHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }
    set = map.keySet();

    keys[3] = keys[3] + 1;
    assertTrue( set.removeAll( keys ) );
    keys[3] = keys[3] - 1;

    assertEquals( "removed: " + keys[3] + ", set: " + set,
            1, set.size() );
    assertEquals( "removed: " + keys[3] + ", set: " + set
                  + "\nmap: " + map, set.size(), map.size() );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:32,代码来源:TPrimitivePrimitiveHashMapTest.java

示例2: testKeySetRetainAllArray

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllArray() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test raw array
    map = new TIntLongHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }
    set = map.keySet();

    assertFalse( set.retainAll( keys ) );
    assertTrue( set.containsAll( keys ) );

    keys[3] = keys[3] + 1;
    assertTrue( set.retainAll( keys ) );
    keys[3] = keys[3] - 1;

    assertEquals( "removed: " + keys[3] + ", set: " + set,
            keys.length - 1, set.size() );
    assertEquals( "removed: " + keys[3] + ", set: " + set
                  + "\nmap: " + map, set.size(), map.size() );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:35,代码来源:TPrimitivePrimitiveHashMapTest.java

示例3: testKeySetEquals

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetEquals() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    TIntSet other = new TIntHashSet();
    other.addAll( keys );

    assertTrue( "sets incorrectly not equal: " + set + ", " + other,
            set.equals( other ) );

    int[] mismatched = {72, 49, 53, 1024, 999};
    TIntSet unequal = new TIntHashSet();
    unequal.addAll( mismatched );

    assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
            set.equals( unequal ) );

    // Change length, different code branch
    unequal.add( 1 );
    assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
            set.equals( unequal ) );

    assertFalse( "set incorrectly equals a random object",
            set.equals( new Object() ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:36,代码来源:TPrimitivePrimitiveHashMapTest.java

示例4: testKeySetRetainAllTCollection

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllTCollection() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    assertFalse( set.retainAll( set ) );

    // test with a TCollection
    TIntSet tintset = new TIntHashSet( keys );
    assertFalse( "set: " + set + ", collection: " + tintset,
            set.retainAll( tintset ) );
    TIntCollection collection = new TIntArrayList( keys );
    assertFalse( "set: " + set + ", collection: " + collection,
            set.retainAll( collection ) );

    collection.remove( 42 );
    assertTrue( "set: " + set + ", collection: " + collection,
            set.retainAll( collection ) );
    assertEquals( keys.length - 1, set.size() );
    assertEquals( keys.length - 1, map.size() );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:31,代码来源:TPrimitivePrimitiveHashMapTest.java

示例5: testKeySetContainsAll

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetContainsAll() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test with a java.util.Map
    Set<Number> java_set = new HashSet<Number>();
    for ( int i = 0; i < keys.length; i++ ) {
        java_set.add( Integer.valueOf( keys[i] ) );
    }
    assertTrue( set.containsAll( java_set ) );
    java_set.add( Integer.valueOf( 12 ) );
    assertFalse( set.containsAll( java_set ) );
    java_set.remove( Integer.valueOf( 12 ) );
    assertTrue( set.containsAll( java_set ) );
    java_set.add( Long.valueOf( 12 ) );
    assertFalse( set.containsAll( java_set ) );

    // test with a TCollection
    TIntSet tintset = new TIntHashSet( keys );
    assertTrue( set.containsAll( tintset ) );
    tintset.add( 12 );
    assertFalse( set.containsAll( tintset ) );

    // test raw array
    assertTrue( set.containsAll( keys ) );
    keys[3] = keys[3] + 1;
    assertFalse( set.containsAll( keys ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:39,代码来源:TPrimitivePrimitiveOffheapHashMapTest.java

示例6: testKeySetRetainAllTCollection

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllTCollection() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    assertFalse( set.retainAll( set ) );

    // test with a TCollection
    TIntSet tintset = new TIntHashSet( keys );
    assertFalse( "set: " + set + ", collection: " + tintset,
            set.retainAll( tintset ) );
    TIntCollection collection = new TIntArrayList( keys );
    assertFalse( "set: " + set + ", collection: " + collection,
            set.retainAll( collection ) );

    collection.remove( 42 );
    assertTrue( "set: " + set + ", collection: " + collection,
            set.retainAll( collection ) );
    assertEquals( keys.length - 1, set.size() );
    assertEquals( keys.length - 1, map.size() );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:31,代码来源:TPrimitivePrimitiveOffheapHashMapTest.java

示例7: testKeySetRetainAllArray

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllArray() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test raw array
    map = new TIntLongOffheapHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }
    set = map.keySet();

    assertFalse( set.retainAll( keys ) );
    assertTrue( set.containsAll( keys ) );

    keys[3] = keys[3] + 1;
    assertTrue( set.retainAll( keys ) );
    keys[3] = keys[3] - 1;

    assertEquals( "removed: " + keys[3] + ", set: " + set,
            keys.length - 1, set.size() );
    assertEquals( "removed: " + keys[3] + ", set: " + set
                  + "\nmap: " + map, set.size(), map.size() );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:35,代码来源:TPrimitivePrimitiveOffheapHashMapTest.java

示例8: testKeySetRetainAllArray

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllArray() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test raw array
    map = new TIntLongHashMap();
    for ( int i = 0; i < keys.length; i++ ) {
        vals[i] = keys[i] * 2;
        map.put( keys[i], vals[i] );
    }
    set = map.keySet();
    
    assertFalse( set.retainAll( keys ) );
    assertTrue( set.containsAll( keys ) );
    
    keys[3] = keys[3] + 1;
    assertTrue( set.retainAll( keys ) );
    keys[3] = keys[3] - 1;

    assertEquals( "removed: " + keys[3] + ", set: " + set,
            keys.length - 1, set.size() );
    assertEquals( "removed: " + keys[3] + ", set: " + set
                  + "\nmap: " + map, set.size(), map.size() );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:35,代码来源:TPrimitivePrimitiveHashMapTest.java

示例9: testKeySetEquals

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetEquals() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    TIntSet other = new TIntHashSet();
    other.addAll( keys );

    assertTrue( "sets incorrectly not equal: " + set + ", " + other,
            set.equals( other ) );

    int[] mismatched = {72, 49, 53, 1024, 999};
    TIntSet unequal = new TIntHashSet();
    unequal.addAll( mismatched );

    assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
            set.equals( unequal ) );

    // Change length, different code branch
    unequal.add( 1 );
    assertFalse( "sets incorrectly equal: " + set + ", " + unequal,
            set.equals( unequal ) );

    assertFalse( "set incorrectly equals a random object",
            set.equals( new Object() ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:36,代码来源:TPrimitivePrimitiveOffheapHashMapTest.java

示例10: testKeySetHashCode

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetHashCode() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );


    TIntSet other = new TIntHashSet();
    other.addAll( keys );

    assertTrue( "hashcodes incorrectly not equal: " + set + ", " + other,
            set.hashCode() == other.hashCode() );

    int[] mismatched = {72, 49, 53, 1024, 999};
    TIntSet unequal = new TIntHashSet();
    unequal.addAll( mismatched );

    assertFalse( "hashcodes unlikely equal: " + set + ", " + unequal,
            set.hashCode() == unequal.hashCode() );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:29,代码来源:TPrimitivePrimitiveOffheapHashMapTest.java

示例11: testKeySetContainsAll

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetContainsAll() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test with a java.util.Map
    Set<Number> java_set = new HashSet<Number>();
    for ( int i = 0; i < keys.length; i++ ) {
        java_set.add( Integer.valueOf( keys[i] ) );
    }
    assertTrue( set.containsAll( java_set ) );
    java_set.add( Integer.valueOf( 12 ) );
    assertFalse( set.containsAll( java_set ) );
    java_set.remove( Integer.valueOf( 12 ) );
    assertTrue( set.containsAll( java_set ) );
    java_set.add( Long.valueOf( 12 ) );
    assertFalse( set.containsAll( java_set ) );

    // test with a TCollection
    TIntSet tintset = new TIntHashSet( keys );
    assertTrue( set.containsAll( tintset ) );
    tintset.add( 12 );
    assertFalse( set.containsAll( tintset ) );

    // test raw array
    assertTrue( set.containsAll( keys ) );
    keys[3] = keys[3] + 1;
    assertFalse( set.containsAll( keys ) );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:39,代码来源:TPrimitivePrimitiveHashMapTest.java

示例12: testKeySetMisc

import gnu.trove.map.TIntLongMap; //导入方法依赖的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

示例13: testKeySetRetainAllCollection

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRetainAllCollection() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test with a java.util.Map
    Set<Number> java_set = new HashSet<Number>();
    for ( int i = 0; i < keys.length; i++ ) {
        java_set.add( Integer.valueOf( keys[i] ) );
    }
    assertFalse( set.retainAll( java_set ) );
    assertEquals( keys.length, set.size() );
    assertEquals( keys.length, map.size() );
    for ( int i = 0; i < keys.length; i++ ) {
        assertTrue( set.contains( keys[i] ) );
        assertTrue( map.containsKey( keys[i] ) );
    }
    java_set.remove( 42 );
    assertTrue( "set should have been modified: " + set + ", java: " + java_set,
            set.retainAll( java_set ) );
    assertEquals( keys.length - 1, set.size() );
    assertEquals( keys.length - 1, map.size() );
    for ( int i = 0; i < keys.length; i++ ) {
        if ( keys[i] != 42 ) {
            assertTrue( set.contains( keys[i] ) );
            assertTrue( map.containsKey( keys[i] ) );
        } else {
            assertFalse( set.contains( keys[i] ) );
            assertFalse( map.containsKey( keys[i] ) );
        }
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:42,代码来源:TPrimitivePrimitiveHashMapTest.java

示例14: testKeySetRemoveAllCollection

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRemoveAllCollection() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test with a java.util.Map
    Set<Number> java_set = new HashSet<Number>();
    assertFalse( set.removeAll( java_set ) );
    assertEquals( keys.length, set.size() );
    assertEquals( keys.length, map.size() );
    for ( int i = 0; i < keys.length; i++ ) {
        assertTrue( set.contains( keys[i] ) );
        assertTrue( map.containsKey( keys[i] ) );
    }

    for ( int i = 0; i < keys.length; i++ ) {
        java_set.add( Integer.valueOf( keys[i] ) );
    }
    java_set.remove( 42 );
    assertTrue( "set should have been modified: " + set + ", java: " + java_set,
            set.removeAll( java_set ) );
    assertEquals( "set: " + set, 1, set.size() );
    assertEquals( "set: " + set, 1, map.size() );
    for ( int i = 0; i < keys.length; i++ ) {
        if ( keys[i] == 42 ) {
            assertTrue( set.contains( keys[i] ) );
            assertTrue( map.containsKey( keys[i] ) );
        } else {
            assertFalse( set.contains( keys[i] ) );
            assertFalse( map.containsKey( keys[i] ) );
        }
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:43,代码来源:TPrimitivePrimitiveHashMapTest.java

示例15: testKeySetRemoveAllCollection

import gnu.trove.map.TIntLongMap; //导入方法依赖的package包/类
public void testKeySetRemoveAllCollection() {
    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();
    assertEquals( map.size(), set.size() );
    assertFalse( set.isEmpty() );

    // test with a java.util.Map
    Set<Number> java_set = new HashSet<Number>();
    assertFalse( set.removeAll( java_set ) );
    assertEquals( keys.length, set.size() );
    assertEquals( keys.length, map.size() );      
    for ( int i = 0; i < keys.length; i++ ) {
        assertTrue( set.contains( keys[i] ) );
        assertTrue( map.containsKey( keys[i] ) );
    }

    for ( int i = 0; i < keys.length; i++ ) {
        java_set.add( Integer.valueOf( keys[i] ) );
    }
    java_set.remove( 42 );
    assertTrue( "set should have been modified: " + set + ", java: " + java_set,
            set.removeAll( java_set ) );
    assertEquals( "set: " + set, 1, set.size() );
    assertEquals( "set: " + set, 1, map.size() );
    for ( int i = 0; i < keys.length; i++ ) {
        if ( keys[i] == 42 ) {
            assertTrue( set.contains( keys[i] ) );
            assertTrue( map.containsKey( keys[i] ) );
        } else {
            assertFalse( set.contains( keys[i] ) );
            assertFalse( map.containsKey( keys[i] ) );
        }
    }
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:43,代码来源:TPrimitivePrimitiveHashMapTest.java


注:本文中的gnu.trove.map.TIntLongMap.keySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。