@SuppressWarnings("unchecked") @Nonnull public <T> T[] toArray(@Nonnull T[] a) { int size = size(); if (a.length < size) { Class<?> elementType = a.getClass().getComponentType(); a = (T[]) java.lang.reflect.Array.newInstance(elementType, size); } if (size == 0) { if (a.length > 0) a[0] = null; return a; } int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { a[resultIndex++] = (T) Byte.valueOf(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = null; return a; }
@Nonnull public byte[] toByteArray() { int size = size(); byte[] result = new byte[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { result[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Nonnull public Object[] toArray() { int size = size(); Object[] result = new Object[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { result[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Nonnull public Object[] toArray() { int size = size(); Object[] result = new Object[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { result[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@Nonnull public byte[] toByteArray() { int size = size(); byte[] result = new byte[size]; if (size == 0) return result; int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { result[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); return result; }
@SuppressWarnings("unchecked") @Nonnull public <T> T[] toArray(@Nonnull T[] a) { int size = size(); if (a.length < size) { Class<?> elementType = a.getClass().getComponentType(); a = (T[]) java.lang.reflect.Array.newInstance(elementType, size); } if (size == 0) { if (a.length > 0) a[0] = null; return a; } int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { a[resultIndex++] = (T) Byte.valueOf(key); } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = null; return a; }
public String setToString() { if (isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { sb.append(' ').append(key).append(','); if (++elementCount == 8) { int expectedLength = sb.length() * (size() / 8); sb.ensureCapacity(expectedLength + (expectedLength / 2)); } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); sb.setCharAt(0, '['); sb.setCharAt(sb.length() - 1, ']'); return sb.toString(); }
public String setToString() { if (isEmpty()) return "[]"; StringBuilder sb = new StringBuilder(); int elementCount = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { sb.append(' ').append(key).append(','); if (++elementCount == 8) { int expectedLength = sb.length() * (size() / 8); sb.ensureCapacity(expectedLength + (expectedLength / 2)); } } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); sb.setCharAt(0, '['); sb.setCharAt(sb.length() - 1, ']'); return sb.toString(); }
@Nonnull public byte[] toArray(byte[] a) { int size = size(); if (a.length < size) a = new byte[size]; if (size == 0) { if (a.length > 0) a[0] = (byte) 0; return a; } int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { a[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = (byte) 0; return a; }
@Nonnull public byte[] toArray(byte[] a) { int size = size(); if (a.length < size) a = new byte[size]; if (size == 0) { if (a.length > 0) a[0] = (byte) 0; return a; } int resultIndex = 0; int mc = modCount(); byte free = freeValue; char[] tab = table; long base = CHAR_BASE + BYTE_KEY_OFFSET; for (long off = ((long) tab.length) << CHAR_SCALE_SHIFT; (off -= CHAR_SCALE) >= 0L;) { byte key; if ((key = U.getByte(tab, base + off)) != free) { a[resultIndex++] = key; } } if (mc != modCount()) throw new java.util.ConcurrentModificationException(); if (a.length > resultIndex) a[resultIndex] = (byte) 0; return a; }