@Test public void testDeleteRow() { LongMatrix<String> m = new LongMatrix<>(2); for (int i = 0; i < 1000; i++) { int r = m.addRow(); m.set(r, 0, i); m.set(r, 1, i); m.set(r, "s" + i); } Assert.assertEquals(1000, m.size()); m.deleteRow(450); Assert.assertEquals(999, m.size()); Assert.assertEquals(451, m.get(450, 0)); Assert.assertEquals(451, m.get(450, 1)); Assert.assertEquals("s" + 451, m.get(450)); Assert.assertEquals(449, m.get(449, 0)); Assert.assertEquals(449, m.get(449, 1)); Assert.assertEquals("s" + 449, m.get(449)); m.deleteRow(998); Assert.assertEquals(998, m.size()); Assert.assertEquals(998, m.get(997, 0)); Assert.assertEquals(998, m.get(997, 1)); Assert.assertEquals("s" + 998, m.get(997)); m.deleteRow(0); Assert.assertEquals(997, m.size()); Assert.assertEquals(998, m.get(996, 0)); Assert.assertEquals(998, m.get(996, 1)); Assert.assertEquals("s" + 998, m.get(996)); }
public void deleteRow(int r) { if (r < pos - 1) { int l = pos - r - 1; int next = r + 1; System.arraycopy(data, next << bits, data, r << bits, l << bits); System.arraycopy(payload, next, payload, r, l); } if (r < pos) { pos--; } }
LongMatrix { public void deleteRow(int r) { if (r < pos - 1) { int l = pos - r - 1; int next = r + 1; System.arraycopy(data, next << bits, data, r << bits, l << bits); System.arraycopy(payload, next, payload, r, l); } if (r < pos) { pos--; } } }
LongMatrix { public void deleteRow(int r) { if (r < pos - 1) { int l = pos - r - 1; int next = r + 1; System.arraycopy(data, next << bits, data, r << bits, l << bits); System.arraycopy(payload, next, payload, r, l); } if (r < pos) { pos--; } } @SuppressWarnings("unchecked")  LongMatrix(int columnCount); }
LongMatrix { public void deleteRow(int r) { if (r < pos - 1) { int l = pos - r - 1; int next = r + 1; System.arraycopy(data, next << bits, data, r << bits, l << bits); System.arraycopy(payload, next, payload, r, l); } if (r < pos) { pos--; } } @SuppressWarnings("unchecked")  LongMatrix(int columnCount); int addRow(); int binarySearch(long v, int index); void deleteRow(int r); long get(int r, int c); T get(int r); void set(int r, T obj); void set(int r, int c, long value); int size(); void zapTop(int count); }
LongMatrix { public void deleteRow(int r) { if (r < pos - 1) { int l = pos - r - 1; int next = r + 1; System.arraycopy(data, next << bits, data, r << bits, l << bits); System.arraycopy(payload, next, payload, r, l); } if (r < pos) { pos--; } } @SuppressWarnings("unchecked")  LongMatrix(int columnCount); int addRow(); int binarySearch(long v, int index); void deleteRow(int r); long get(int r, int c); T get(int r); void set(int r, T obj); void set(int r, int c, long value); int size(); void zapTop(int count);  }