Example usage for org.apache.commons.collections.primitives ArrayIntList removeElementAt

List of usage examples for org.apache.commons.collections.primitives ArrayIntList removeElementAt

Introduction

In this page you can find the example usage for org.apache.commons.collections.primitives ArrayIntList removeElementAt.

Prototype

public int removeElementAt(int index) 

Source Link

Document

Removes the element at the specified position in (optional operation).

Usage

From source file:dbs_project.storage.functional.TableTest.java

@Test(timeout = 300000L)
public void testDeleteRows() throws Exception {
    Utils.getOut().println("testDeleteRows");
    final Map<String, TableCreationResult> tableCreateResults = TestTableBuilder
            .createTablesAndAddRows(StorageLayerTest.TABLE_NAMES, storage);
    for (final TableCreationResult artifacts : tableCreateResults.values()) {
        final Table toTestTable = artifacts.getTable();
        final List<SimpleColumn> referenceSimpleColumnList = artifacts.getColumns();
        final ArrayIntList idList = artifacts.getGeneratedIds();
        final ArrayIntList deleteReferenceList = new ArrayIntList();
        final ArrayIntList deleteTotestList = new ArrayIntList();
        //delete list backwards, so that indexes remain stable
        for (int i = idList.size(); --i >= 0;) {
            if (Utils.RANDOM.nextInt() % DELETE_ROW_FACTOR == 0) {
                deleteReferenceList.add(i);
                deleteTotestList.add(idList.get(i));
                idList.removeElementAt(i);
            }/*from w w w  .  j  ava2 s .c  om*/
        }
        for (final SimpleColumn referenceColumn : referenceSimpleColumnList) {
            for (int i = 0; i < deleteTotestList.size(); ++i) {
                referenceColumn.remove(deleteReferenceList.get(i));
            }
        }
        toTestTable.deleteRows(IntIteratorWrapper.wrap(deleteTotestList.iterator()));
        final RowCursor toTestCursor = toTestTable.getRows(IntIteratorWrapper.wrap(idList.iterator()));
        final RowCursor referenceCursor = new SimpleRowCursor(referenceSimpleColumnList);
        assertTrue("result is different from reference: deleteRows",
                Utils.compareRowCursors(referenceCursor, toTestCursor));
        //            For debug purposes. Comment out the assertion above before use.
        //            Utils.getOut().println(Utils.rowCursorToHtmlTable(toTestCursor, true));
        //            Utils.getOut().println(Utils.rowCursorToHtmlTable(referenceCursor, true));
        toTestCursor.close();
        referenceCursor.close();
    }
}