本文整理匯總了Java中gnu.trove.set.TIntSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java TIntSet.size方法的具體用法?Java TIntSet.size怎麽用?Java TIntSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類gnu.trove.set.TIntSet
的用法示例。
在下文中一共展示了TIntSet.size方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: equals
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
/** {@inheritDoc) */
public boolean equals( Object other ) {
if (! ( other instanceof TIntSet ) ) {
return false;
}
final TIntSet that = ( TIntSet ) other;
if ( that.size() != this.size() ) {
return false;
}
for ( int i = _states.length; i-- > 0; ) {
if ( _states[i] == FULL ) {
if ( ! that.contains( _set[i] ) ) {
return false;
}
}
}
return true;
}
示例2: equals
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
/** {@inheritDoc} */
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntSet ) ) {
return false;
}
TIntSet that = ( TIntSet ) other;
if ( that.size() != this.size() ) {
return false;
}
for ( int i = _states.length; i-- > 0; ) {
if ( _states[i] == FULL ) {
if ( ! that.contains( _set[i] ) ) {
return false;
}
}
}
return true;
}
示例3: equals
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public boolean equals( Object other ) {
if (! ( other instanceof TIntSet ) ) {
return false;
}
final TIntSet that = ( TIntSet ) other;
if ( that.size() != this.size() ) {
return false;
}
for ( int i = _states.length; i-- > 0; ) {
if ( _states[i] == FULL ) {
if ( ! that.contains( _set[i] ) ) {
return false;
}
}
}
return true;
}
示例4: distinct
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
@Override
public final Array<Integer> distinct(int limit) {
final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
final TIntSet set = new TIntHashSet(capacity);
final ArrayBuilder<Integer> builder = ArrayBuilder.of(capacity, Integer.class);
for (int i=0; i<length(); ++i) {
final int value = getInt(i);
if (set.add(value)) {
builder.addInt(value);
if (set.size() >= limit) {
break;
}
}
}
return builder.toArray();
}
示例5: distinct
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
@Override
public Array<T> distinct(int limit) {
final int capacity = limit < Integer.MAX_VALUE ? limit : 100;
final TIntSet set = new TIntHashSet(capacity);
final ArrayBuilder<T> builder = ArrayBuilder.of(capacity, type());
for (int i=0; i<length(); ++i) {
final int code = getInt(i);
if (set.add(code)) {
final T value = getValue(i);
builder.add(value);
if (set.size() >= limit) {
break;
}
}
}
return builder.toArray();
}
示例6: testKeySetHashCode
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetHashCode() {
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() );
assertEquals( keyset.hashCode(), keyset.hashCode() );
TIntSet other = new TIntHashSet( keys );
other.add( 1138 );
assertTrue( keyset.hashCode() != other.hashCode() );
}
示例7: equals
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
/** {@inheritDoc) */
@Override
public boolean equals( Object other ) {
if (! ( other instanceof TIntSet ) ) {
return false;
}
final TIntSet that = ( TIntSet ) other;
if ( that.size() != this.size() ) {
return false;
}
for ( int i = _states.length; i-- > 0; ) {
if ( _states[i] == FULL ) {
if ( ! that.contains( _set[i] ) ) {
return false;
}
}
}
return true;
}
示例8: equals
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntSet ) ) {
return false;
}
TIntSet that = ( TIntSet ) other;
if ( that.size() != this.size() ) {
return false;
}
for ( int i = capacity(); i-- > 0; ) {
if ( _states.get(i) == FULL ) {
if ( ! that.contains( _set.get( i ) ) ) {
return false;
}
}
}
return true;
}
示例9: equals
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntSet ) ) {
return false;
}
TIntSet that = ( TIntSet ) other;
if ( that.size() != this.size() ) {
return false;
}
for ( int i = _states.length; i-- > 0; ) {
if ( _states[i] == FULL ) {
if ( ! that.contains( _set[i] ) ) {
return false;
}
}
}
return true;
}
示例10: testKeySetContainsAllCollection
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetContainsAllCollection() {
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] );
}
assertTrue( keyset.containsAll( test_collection ) ) ;
test_collection.remove( Integer.valueOf( keys[5] ) );
assertTrue( "should contain all. keyset: " + keyset + ", " + test_collection,
keyset.containsAll( test_collection ) );
test_collection.add( Integer.valueOf( 1138 ) );
assertFalse( "should not contain all. keyset: " + keyset + ", " + test_collection,
keyset.containsAll( test_collection ) );
}
示例11: testKeySetContainsAllTCollection
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetContainsAllTCollection() {
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() );
TIntCollection test_collection = new TIntHashSet();
for ( int i = 0; i < element_count; i++ ) {
test_collection.add( keys[i] );
}
assertTrue( keyset.containsAll( test_collection ) ) ;
assertTrue( keyset.equals( keyset ) );
test_collection.remove( Integer.valueOf( keys[5] ) );
assertTrue( "should contain all. keyset: " + keyset + ", " + test_collection,
keyset.containsAll( test_collection ) );
test_collection.add( 1138 );
assertFalse( "should not contain all. keyset: " + keyset + ", " + test_collection,
keyset.containsAll( test_collection ) );
}
示例12: testKeySetContainsAllArray
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetContainsAllArray() {
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() );
assertTrue( "should contain all. keyset: " + keyset + ", " + Arrays.toString( keys ),
keyset.containsAll( keys ) );
int[] other_array = new int[ keys.length + 1 ];
System.arraycopy( keys, 0, other_array, 0, keys.length );
other_array[other_array.length - 1] = 1138;
assertFalse( "should not contain all. keyset: " + keyset + ", " + Arrays.toString( other_array ),
keyset.containsAll( other_array ) );
}
示例13: testKeySetEqual
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetEqual() {
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() );
TIntSet other = new TIntHashSet();
other.addAll( keys );
assertTrue( "sets incorrectly not equal: " + keyset + ", " + other,
keyset.equals( other ) );
int[] mismatched = {72, 49, 53, 1024, 999};
TIntSet unequal = new TIntHashSet();
unequal.addAll( mismatched );
assertFalse( "sets incorrectly equal: " + keyset + ", " + unequal,
keyset.equals( unequal ) );
// Change length, different code branch
unequal.add( 1 );
assertFalse( "sets incorrectly equal: " + keyset + ", " + unequal,
keyset.equals( unequal ) );
//noinspection ObjectEqualsNull
assertFalse( keyset.equals( null ) );
}
示例14: testKeySetRetainAllArray
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetRetainAllArray() {
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() );
assertFalse( "keyset: " + keyset + ", should be unmodified. array: " +
Arrays.toString( keys ), keyset.retainAll( keys ) );
int[] other = new int[element_count - 1];
for ( int i = 0; i < element_count; i++ ) {
if ( i < 5 ) {
other[i] = i + 1;
}
if ( i > 5 ) {
other[i - 1] = i + 1;
}
}
assertTrue( "keyset: " + keyset + ", should be modified. array: " +
Arrays.toString( other ), keyset.retainAll( other ) );
}
示例15: testKeySetRetainAllTCollection
import gnu.trove.set.TIntSet; //導入方法依賴的package包/類
public void testKeySetRetainAllTCollection() {
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() );
assertFalse( "keyset: " + keyset + ", should be unmodified.",
keyset.retainAll( keyset ) );
TIntCollection other = new TIntArrayList( keyset );
assertFalse( "keyset: " + keyset + ", should be unmodified. other: " +
other, keyset.retainAll( other ) );
other.remove( keys[5] );
assertTrue( "keyset: " + keyset + ", should be modified. other: " +
other, keyset.retainAll( other ) );
assertFalse( keyset.contains( keys[5] ) );
assertFalse( map.containsKey( keys[5] ) );
assertFalse( map.containsValue( vals[5] ) );
assertTrue( "keyset: " + keyset + ", should contain all in other: " +
other, keyset.containsAll( other ) );
}