本文整理汇总了Java中gnu.trove.list.TIntList.size方法的典型用法代码示例。如果您正苦于以下问题:Java TIntList.size方法的具体用法?Java TIntList.size怎么用?Java TIntList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.list.TIntList
的用法示例。
在下文中一共展示了TIntList.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: equals
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( other == this ) {
return true;
}
if ( !( other instanceof TIntList ) ) return false;
TIntList that = ( TIntList )other;
if ( size() != that.size() ) return false;
for( int i = 0; i < size(); i++ ) {
if ( get( i ) != that.get( i ) ) {
return false;
}
}
return true;
}
示例2: testGrep
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testGrep() {
int element_count = 20;
TIntList a = new TIntLinkedList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
TIntList grepped = a.grep( new TIntProcedure() {
@Override
public boolean execute( int value ) {
return value > 10;
}
} );
for ( int i = 0; i < grepped.size(); i++ ) {
int expected = i + 11;
assertEquals( expected, grepped.get( i ) );
}
}
示例3: testInverseGrep
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testInverseGrep() {
int element_count = 20;
TIntList a = new TIntLinkedList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
TIntList grepped = a.inverseGrep( new TIntProcedure() {
public boolean execute( int value ) {
return value <= 10;
}
} );
for ( int i = 0; i < grepped.size(); i++ ) {
int expected = i + 11;
assertEquals( expected, grepped.get( i ) );
}
}
示例4: testRemoveMultiple
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testRemoveMultiple() {
int element_count = 20;
TIntList a = new TIntLinkedList();
assertTrue( a.isEmpty() );
for ( int i = 1; i <= element_count; i++ ) {
a.add( i );
}
// Remove odd offsets, which are even numbers.
for ( int i = element_count; i >= 0; i-- ) {
if ( i % 2 == 1 ) {
a.removeAt( i );
}
}
for ( int i = 0; i < a.size(); i++ ) {
int expected = i * 2 + 1;
assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected );
}
}
示例5: testTransform
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testTransform() {
int element_count = 20;
TIntList a = new TIntOffheapArrayList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
a.transformValues( new TIntFunction() {
@Override
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < a.size(); i++ ) {
int result = a.get( i );
int expected = ( i + 1 ) * ( i + 1 );
assertEquals( expected, result );
}
}
示例6: testGrep
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testGrep() {
int element_count = 20;
TIntList a = new TIntLinkedList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
TIntList grepped = a.grep( new TIntProcedure() {
public boolean execute( int value ) {
return value > 10;
}
} );
for ( int i = 0; i < grepped.size(); i++ ) {
int expected = i + 11;
assertEquals( expected, grepped.get( i ) );
}
}
示例7: testSortPartial
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testSortPartial() {
int element_count = 20;
TIntList a = new TIntLinkedList();
for ( int i = 1; i <= element_count; i++ ) {
a.add( i );
}
a.reverse();
a.sort( 5, 15 );
int[] expected = {20, 19, 18, 17, 16, 6, 7, 8, 9, 10,
11, 12, 13, 14, 15, 5, 4, 3, 2, 1};
for ( int i = 0; i < a.size(); i++ ) {
assertEquals( expected[i], a.get( i ) );
}
try {
a.sort( 20, 10 );
fail( "Expected IllegalArgumentException" );
}
catch ( IllegalArgumentException ex ) {
// Expected
}
}
示例8: testInsertAtEnd
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testInsertAtEnd() {
int element_count = 10;
TIntList a = new TIntArrayList();
assertTrue( a.isEmpty() );
for ( int i = 1; i <= element_count; i++ ) {
a.add( i );
}
a.insert( a.size(), 11 );
for ( int i = 0; i < element_count; i++ ) {
assertEquals( i + 1, a.get( i ) );
}
for ( int i = element_count;
i < a.size();
i++ ) {
int expected = i + 1;
assertEquals( expected, a.get( i ) );
}
}
示例9: testInverseGrep
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testInverseGrep() {
int element_count = 20;
TIntList a = new TIntArrayList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
TIntList grepped = a.inverseGrep( new TIntProcedure() {
public boolean execute( int value ) {
return value <= 10;
}
} );
for ( int i = 0; i < grepped.size(); i++ ) {
int expected = i + 11;
assertEquals( expected, grepped.get( i ) );
}
}
示例10: testGrep
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testGrep() {
int element_count = 20;
TIntList a = new TIntArrayList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
TIntList grepped = a.grep( new TIntProcedure() {
@Override
public boolean execute( int value ) {
return value > 10;
}
} );
for ( int i = 0; i < grepped.size(); i++ ) {
int expected = i + 11;
assertEquals( expected, grepped.get( i ) );
}
}
示例11: testRemoveMultiple
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testRemoveMultiple() {
int element_count = 20;
TIntList a = new TIntArrayList();
assertTrue( a.isEmpty() );
for ( int i = 1; i <= element_count; i++ ) {
a.add( i );
}
// Remove odd offsets, which are even numbers.
for ( int i = element_count; i >= 0; i-- ) {
if ( i % 2 == 1 ) {
a.removeAt( i );
}
}
for ( int i = 0; i < a.size(); i++ ) {
int expected = i * 2 + 1;
assertTrue( "index " + i + " expected " + expected, a.get( i ) == expected );
}
}
示例12: testSetArray
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testSetArray() {
int element_count = 10;
int[] ints = {1138, 42, 86, 99, 101};
TIntList a = new TIntOffheapArrayList();
assertTrue( a.isEmpty() );
for ( int i = 1; i <= element_count; i++ ) {
a.add( i );
}
a.set( a.size() - ints.length, ints );
for ( int i = 0; i < element_count - ints.length; i++ ) {
assertEquals( i + 1, a.get( i ) );
}
for ( int i = element_count - ints.length, j = 0;
i < a.size();
i++, j++ ) {
assertEquals( ints[j], a.get( i ) );
}
try {
a.set( a.size(), ints );
fail( "Expected IndexOutOfBoundsException" );
}
catch ( IndexOutOfBoundsException ex ) {
// Expected
}
}
示例13: testRetainAllArray
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testRetainAllArray() {
int element_count = 20;
int ints[] = new int[element_count];
for ( int i = 0; i < element_count; i++ ) {
ints[i] = i;
}
TIntList list = new TIntArrayList( 20 );
for ( int i = 0; i < element_count; i++ ) {
list.add( i );
}
assertEquals( element_count, list.size() );
assertFalse( list.retainAll( ints ) );
assertEquals( element_count, list.size() );
for ( int i = 0; i < list.size(); i++ ) {
assertEquals( i , list.get( i ) );
}
ints = new int[( element_count - 4 )] ;
for ( int i = 0, j = 0; i < ints.length; i++, j++ ) {
if ( i % 4 == 0 ) {
j++;
}
ints[i] = j;
}
assertTrue( list.retainAll( ints ) );
int expected = element_count - 4;
assertEquals( expected, list.size() );
for ( int i = 0; i < list.size(); i++ ) {
expected = ( int ) Math.floor( i / 4 ) + i + 1;
assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list,
expected , list.get( i ) );
}
}
示例14: testShuffle
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testShuffle() {
int element_count = 20;
TIntList list = new TIntArrayList( 20 );
for ( int i = 0; i < element_count; i++ ) {
list.add( i );
}
list.shuffle( new Random( System.currentTimeMillis() ) );
for ( int i = 0; i < list.size(); i++ ) {
assertTrue( list.contains( i ) );
}
}
示例15: testRetainAllTCollection
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testRetainAllTCollection() {
int element_count = 20;
TIntList other = new TIntLinkedList();
for ( int i = 0; i < element_count; i++ ) {
other.add( i );
}
TIntList list = new TIntLinkedList( 20 );
for ( int i = 0; i < element_count; i++ ) {
list.add( i );
}
assertEquals( element_count, list.size() );
assertEquals( element_count, other.size() );
assertFalse( list.retainAll( list ) );
assertFalse( list.retainAll( other ) );
assertEquals( element_count, list.size() );
for ( int i = 0; i < list.size(); i++ ) {
assertEquals( i , list.get( i ) );
}
other.remove( 0 );
other.remove( 5 );
other.remove( 10 );
other.remove( 15 );
assertTrue( list.retainAll( other ) );
int expected = element_count - 4;
assertEquals( expected, list.size() );
for ( int i = 0; i < list.size(); i++ ) {
expected = ( int ) Math.floor( i / 4 ) + i + 1;
assertEquals( "expected: " + expected + ", was: " + list.get( i ) + ", list: " + list,
expected , list.get( i ) );
}
}