@Test public void testRemoveAt() { try { array.removeAt(10001, 1); assertTrue("Failed to detect row out of bounds", false); } catch (ArrayIndexOutOfBoundsException ae) { assertTrue(true); } try { array.removeAt(1, 10001); assertTrue("Failed to detect col out of bounds", false); } catch (ArrayIndexOutOfBoundsException ae) { assertTrue(true); } array.putAt(10, 100, "C"); array.putAt(30, 140, "D"); array.putAt(10, 150, "L"); array.putAt(30, 150, "E"); array.putAt(7, 7, "T"); assertEquals("Removed element from non-existent cell not null", null, array.removeAt(5, 5)); assertEquals("Removed element wrong", "C", array.removeAt(10, 100)); assertEquals("Removed element wrong", "L", array.removeAt(10, 150)); List<String> list = array.getRowFor(10); assertTrue(list.isEmpty()); list = array.getColumnFor(100); assertTrue(list.isEmpty()); list = array.getColumnFor(150); assertTrue(list.size() == 1); assertTrue(list.contains("E")); assertEquals("Single element row, col remove wrong", "T", array.removeAt(7, 7)); list = array.getRowFor(7); assertTrue(list.isEmpty()); list = array.getColumnFor(7); assertTrue(list.isEmpty()); }
@Override public T removeAt(int row, int col) throws ArrayIndexOutOfBoundsException { if (row>this.row || row<1 || col>column || col<1){ throw new ArrayIndexOutOfBoundsException(); } else if (isEmpty()==true){ return null; } else{ T returnValue = removeFromRow(row,col); removeFromCol(row,col); return returnValue; } }
SparseArray2DImpl implements ISparseArray2D<T> { @Override public T removeAt(int row, int col) throws ArrayIndexOutOfBoundsException { if (row>this.row || row<1 || col>column || col<1){ throw new ArrayIndexOutOfBoundsException(); } else if (isEmpty()==true){ return null; } else{ T returnValue = removeFromRow(row,col); removeFromCol(row,col); return returnValue; } } }
SparseArray2DImpl implements ISparseArray2D<T> { @Override public T removeAt(int row, int col) throws ArrayIndexOutOfBoundsException { if (row>this.row || row<1 || col>column || col<1){ throw new ArrayIndexOutOfBoundsException(); } else if (isEmpty()==true){ return null; } else{ T returnValue = removeFromRow(row,col); removeFromCol(row,col); return returnValue; } } SparseArray2DImpl(int row, int column); }
SparseArray2DImpl implements ISparseArray2D<T> { @Override public T removeAt(int row, int col) throws ArrayIndexOutOfBoundsException { if (row>this.row || row<1 || col>column || col<1){ throw new ArrayIndexOutOfBoundsException(); } else if (isEmpty()==true){ return null; } else{ T returnValue = removeFromRow(row,col); removeFromCol(row,col); return returnValue; } } SparseArray2DImpl(int row, int column); @Override void putAt(int row, int col, T value); @Override T removeAt(int row, int col); @Override T getAt(int row, int col); @Override List<T> getRowFor(int row); @Override List<T> getColumnFor(int col); }
SparseArray2DImpl implements ISparseArray2D<T> { @Override public T removeAt(int row, int col) throws ArrayIndexOutOfBoundsException { if (row>this.row || row<1 || col>column || col<1){ throw new ArrayIndexOutOfBoundsException(); } else if (isEmpty()==true){ return null; } else{ T returnValue = removeFromRow(row,col); removeFromCol(row,col); return returnValue; } } SparseArray2DImpl(int row, int column); @Override void putAt(int row, int col, T value); @Override T removeAt(int row, int col); @Override T getAt(int row, int col); @Override List<T> getRowFor(int row); @Override List<T> getColumnFor(int col);  }