本文整理汇总了Java中gnu.trove.list.TIntList.clear方法的典型用法代码示例。如果您正苦于以下问题:Java TIntList.clear方法的具体用法?Java TIntList.clear怎么用?Java TIntList.clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.list.TIntList
的用法示例。
在下文中一共展示了TIntList.clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testSum
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testSum() {
TIntList list = new TIntArrayList();
assertEquals(0, list.sum());
list.add(1);
assertEquals(1, list.sum());
list.add(1234);
assertEquals(1235, list.sum());
list.removeAt(0);
assertEquals(1234, list.sum());
list.clear();
assertEquals(0, list.sum());
}
示例2: testSum
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testSum() {
TIntList list = new TIntLinkedList();
assertEquals( 0, list.sum() );
list.add( 1 );
assertEquals( 1, list.sum() );
list.add( 1234 );
assertEquals( 1235, list.sum() );
list.removeAt( 0 );
assertEquals( 1234, list.sum() );
list.clear();
assertEquals( 0, list.sum() );
}
示例3: testSum
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testSum() {
TIntList list = new TIntLinkedList();
assertEquals( 0, list.sum() );
list.add( 1 );
assertEquals( 1, list.sum() );
list.add( 1234 );
assertEquals( 1235, list.sum() );
list.removeAt( 0 );
assertEquals( 1234, list.sum() );
list.clear();
assertEquals( 0, list.sum() );
}
示例4: testIntListDecorator
import gnu.trove.list.TIntList; //导入方法依赖的package包/类
public void testIntListDecorator() {
TIntList list = new TIntArrayList();
list.add( 2 );
list.add( 3 );
list.add( 4 );
list.add( 5 );
list.add( 6 );
List<Integer> wrapped_list = TDecorators.wrap( list );
assertEquals( 5, wrapped_list.size() );
assertEquals( Integer.valueOf( 2 ), wrapped_list.get( 0 ) );
assertEquals( Integer.valueOf( 3 ), wrapped_list.get( 1 ) );
assertEquals( Integer.valueOf( 4 ), wrapped_list.get( 2 ) );
assertEquals( Integer.valueOf( 5 ), wrapped_list.get( 3 ) );
assertEquals( Integer.valueOf( 6 ), wrapped_list.get( 4 ) );
list.removeAt( 1 );
assertEquals( 4, list.size() );
assertEquals( Integer.valueOf( 2 ), wrapped_list.get( 0 ) );
assertEquals( Integer.valueOf( 4 ), wrapped_list.get( 1 ) );
assertEquals( Integer.valueOf( 5 ), wrapped_list.get( 2 ) );
assertEquals( Integer.valueOf( 6 ), wrapped_list.get( 3 ) );
wrapped_list.remove( 1 );
assertEquals( 3, list.size() );
assertEquals( 2, list.get( 0 ) );
assertEquals( 5, list.get( 1 ) );
assertEquals( 6, list.get( 2 ) );
list.clear();
assertTrue( wrapped_list.isEmpty() );
wrapped_list.add( Integer.valueOf( 7 ) );
assertEquals( 1, list.size() );
assertEquals( 7, list.get( 0 ) );
wrapped_list.clear();
assertTrue( list.isEmpty() );
list.add( 8 );
list.add( 9 );
list.add( 10 );
Iterator<Integer> wrapper_list_it = wrapped_list.iterator();
assertTrue( wrapper_list_it.hasNext() );
assertEquals( Integer.valueOf( 8 ), wrapper_list_it.next() );
assertTrue( wrapper_list_it.hasNext() );
assertEquals( Integer.valueOf( 9 ), wrapper_list_it.next() );
assertTrue( wrapper_list_it.hasNext() );
assertEquals( Integer.valueOf( 10 ), wrapper_list_it.next() );
assertFalse( wrapper_list_it.hasNext() );
wrapper_list_it = wrapped_list.iterator();
assertTrue( wrapper_list_it.hasNext() );
assertEquals( Integer.valueOf( 8 ), wrapper_list_it.next() );
wrapper_list_it.remove();
assertTrue( wrapper_list_it.hasNext() );
assertEquals( Integer.valueOf( 9 ), wrapper_list_it.next() );
assertTrue( wrapper_list_it.hasNext() );
assertEquals( Integer.valueOf( 10 ), wrapper_list_it.next() );
assertFalse( wrapper_list_it.hasNext() );
assertEquals( 2, list.size() );
assertEquals( 9, list.get( 0 ) );
assertEquals( 10, list.get( 1 ) );
}