@Override public String getString(int id) { assert id < _idToValueMap.size(); return (Integer.valueOf(_idToValueMap.getInt(id)).toString()); } }
/** * Recount the amount of non-air blocks in the chunk section. */ public void recount() { count = 0; for (int i = 0; i < ARRAY_SIZE; i++) { int type = data.get(i); if (palette != null) { type = palette.getInt(type); } if (type != 0) { count++; } } }
/** * Returns the block type array. Do not modify this array. * * @return The block type array. */ public char[] getTypes() { char[] types = new char[ARRAY_SIZE]; for (int i = 0; i < ARRAY_SIZE; i++) { int type = data.get(i); if (palette != null) { type = palette.getInt(type); } types[i] = (char) type; } return types; }
/** * Return an estimated selectivity for bitmaps for the dimension values given by dimValueIndexes. * * @param bitmapIndex bitmap index * @param bitmaps bitmaps to extract, by index * @param totalNumRows number of rows in the column associated with this bitmap index * * @return estimated selectivity */ public static double estimateSelectivity( final BitmapIndex bitmapIndex, final IntList bitmaps, final long totalNumRows ) { long numMatchedRows = 0; for (int i = 0; i < bitmaps.size(); i++) { final ImmutableBitmap bitmap = bitmapIndex.getBitmap(bitmaps.getInt(i)); numMatchedRows += bitmap.size(); } return Math.min(1., (double) numMatchedRows / totalNumRows); }
/** * Gets the type at the given coordinates. * * @param x The x coordinate, for east and west. * @param y The y coordinate, for up and down. * @param z The z coordinate, for north and south. * @return A type ID */ public char getType(int x, int y, int z) { int value = data.get(index(x, y, z)); if (palette != null) { value = palette.getInt(value); } return (char) value; }
@Test public void testRangeIntList() { final IntList list = IntListUtils.fromTo(20, 120); for (int i = 0; i < 100; i++) { assertEquals(i + 20, list.getInt(i)); } } }
@Test(expected = IndexOutOfBoundsException.class) public void testEmptyRangeIntList() { final IntList list = IntListUtils.fromTo(10, 10); assertEquals(0, list.size()); list.getInt(0); }
@Override public Entity get(int index) { return entityBuilder.apply(positions.getInt(index)); }
int newValue = palette.getInt(oldValue); data.set(i, newValue);
BlockBuilder singleMapWriter = multimapBlockBuilder.beginBlockEntry(); for (int i = 0; i < keySet.size(); i++) { keyType.appendTo(rowType.getObject(block, entryIndicesList[i].getInt(0)), 0, singleMapWriter); BlockBuilder singleArrayWriter = singleMapWriter.beginBlockEntry(); for (int entryIndex : entryIndicesList[i]) {
@Override public int getInt(final int i) { synchronized (sync) { return list.getInt(i); } } @Override
@Override public int getInt(final int i) { return list.getInt(i); } @Override
@Test public void testBroaderInterval() { IntList list = new IntIntervalList(5); assertFalse(list.isEmpty()); assertEquals(5, list.size()); for (int i = 0; i < 5; i++) { assertEquals(i, list.getInt(i)); } try { list.getInt(5); fail("getInt(5) should throw"); } catch (IndexOutOfBoundsException e) { /* no-op */ } } }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Integer get(int index) { return Integer.valueOf(getInt(index)); } /**
@Override public int previousInt() { if (!hasPrevious()) throw new NoSuchElementException(); return l.getInt(from + (last = --pos)); } @Override
@Override public int getInt(long index) { return list.getInt(intIndex(index)); } @Override
static <T> ImmutableList<T> replace(ImmutableList<T> list, IntList indices, ImmutableList<T> elements) { checkIndices(indices, elements); final List<T> newL = newArrayList(list); for (int i = 0; i < indices.size(); i++) { newL.set(indices.getInt(i), elements.get(i)); } return ImmutableList.copyOf(newL); }
@Test public void testSimpleListAccess() { IntList list = new IntIntervalList(1); assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(0, list.getInt(0)); try { list.getInt(1); fail("getInt(1) should throw"); } catch (IndexOutOfBoundsException e) { /* no-op */ } IntListIterator iter = list.iterator(); assertTrue(iter.hasNext()); assertFalse(iter.hasPrevious()); assertEquals(0, iter.nextInt()); assertFalse(iter.hasNext()); assertTrue(iter.hasPrevious()); assertEquals(0, iter.previousInt()); }
@Test public void testSimpleIntervalAccess() { IntList list = new IntIntervalList(42, 43); assertFalse(list.isEmpty()); assertEquals(1, list.size()); assertEquals(42, list.getInt(0)); try { list.getInt(1); fail("getInt(1) should throw"); } catch (IndexOutOfBoundsException e) { /* no-op */ } IntListIterator iter = list.iterator(); assertTrue(iter.hasNext()); assertFalse(iter.hasPrevious()); assertEquals(42, iter.nextInt()); assertFalse(iter.hasNext()); assertTrue(iter.hasPrevious()); assertEquals(42, iter.previousInt()); }
static DoubleList replace(DoubleList list, IntList indices, DoubleList elements) { checkIndices(indices, elements); final DoubleList newL = new DoubleArrayList(list); for (int i = 0; i < indices.size(); i++) { newL.set(indices.getInt(i), elements.getDouble(i)); } return DoubleLists.unmodifiable(newL); }