@Override public int size() { return values.size(); }
@Override public int size() { return cells.size(); }
private void rangeCheck(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(); } }
@Override public Cell get(int index) { rangeCheck(index); int numNonNullElementsFound = 0; for (int i = firstNonNullElementIdx; i < array.length; i++) { if (array[i] != null) { numNonNullElementsFound++; if (numNonNullElementsFound == index + 1) { return array[i]; } } } throw new IllegalStateException("There was no element present in the list at index " + index + " even though number of elements in the list are " + size()); }
@Test public void testSize() { EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS); assertEquals(0, list.size()); populateList(list); assertEquals(7, list.size()); int originalSize = list.size(); Iterator itr = list.iterator(); while (itr.hasNext()) { itr.next(); itr.remove(); assertEquals(--originalSize, list.size()); } }
@Override public int size() { return values.size(); }
@Override public int size() { return cells.size(); }
@Override public int size() { return values.size(); }
@Override public int size() { return cells.size(); }
@Test public void testRemove() throws Exception { EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS); Cell[] cells = new Cell[7]; populateListAndArray(list, cells); assertTrue(list.remove(cells[0])); assertEquals(6, list.size()); assertTrue(list.remove(cells[6])); assertEquals(5, list.size()); assertTrue(list.remove(cells[3])); assertEquals(4, list.size()); assertFalse(list.remove(KeyValueUtil.createFirstOnRow(row, cf, FOUR_BYTE_QUALIFIERS.encode(13)))); assertEquals(4, list.size()); }
assertEquals(7, list.size());
assertEquals(7, list.size());
private void rangeCheck(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(); } }
private void rangeCheck(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException(); } }
@Test public void testClear() throws Exception { EncodedColumnQualiferCellsList list = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS); populateList(list); list.clear(); assertTrue(list.isEmpty()); assertEquals(0, list.size()); }
@Test public void testRetainAll() throws Exception { EncodedColumnQualiferCellsList list1 = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS); populateList(list1); EncodedColumnQualiferCellsList list2 = new EncodedColumnQualiferCellsList(11, 16, FOUR_BYTE_QUALIFIERS); populateList(list2); // retainAll won't be modifying the list1 since they both have the same elements equality wise assertFalse(list1.retainAll(list2)); list2.remove(KeyValueUtil.createFirstOnRow(row, cf, FOUR_BYTE_QUALIFIERS.encode(12))); assertTrue(list1.retainAll(list2)); assertEquals(list1.size(), list2.size()); for (Cell c : list1) { assertTrue(list2.contains(c)); } }
@Override public Cell get(int index) { rangeCheck(index); int numNonNullElementsFound = 0; for (int i = firstNonNullElementIdx; i < array.length; i++) { if (array[i] != null) { numNonNullElementsFound++; if (numNonNullElementsFound == index + 1) { return array[i]; } } } throw new IllegalStateException("There was no element present in the list at index " + index + " even though number of elements in the list are " + size()); }
@Override public Cell get(int index) { rangeCheck(index); int numNonNullElementsFound = 0; for (int i = firstNonNullElementIdx; i < array.length; i++) { if (array[i] != null) { numNonNullElementsFound++; if (numNonNullElementsFound == index + 1) { return array[i]; } } } throw new IllegalStateException("There was no element present in the list at index " + index + " even though number of elements in the list are " + size()); }