@Test public void testToArray() { NodeImpl[] nodes = new NodeImpl[] { new NodeImpl("0"), new NodeImpl("1"), new NodeImpl("2") }; NodeStore nodeStore = new NodeStore(); Assert.assertEquals(new NodeImpl[0], nodeStore.toArray()); nodeStore.addAll(Arrays.asList(nodes)); Assert.assertEquals(nodes, nodeStore.toArray()); Assert.assertEquals(nodes, nodeStore.toArray(new Node[0])); nodeStore.clear(); Assert.assertEquals(new NodeImpl[0], nodeStore.toArray()); }
@Override public NodeImpl[] toArray() { readLock(); NodeImpl[] array = new NodeImpl[size]; if (garbageSize == 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock block = blocks[i]; System.arraycopy(block.backingArray, 0, array, block.offset, block.nodeLength); } } else { NodeStoreIterator itr = iterator(); int offset = 0; while (itr.hasNext()) { NodeImpl n = itr.next(); array[offset++] = n; } } readUnlock(); return array; }
NodeStore implements Collection<Node>, NodeIterable { @Override public NodeImpl[] toArray() { readLock(); NodeImpl[] array = new NodeImpl[size]; if (garbageSize == 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock block = blocks[i]; System.arraycopy(block.backingArray, 0, array, block.offset, block.nodeLength); } } else { NodeStoreIterator itr = iterator(); int offset = 0; while (itr.hasNext()) { NodeImpl n = itr.next(); array[offset++] = n; } } readUnlock(); return array; } }
NodeStore implements Collection<Node>, NodeIterable { @Override public NodeImpl[] toArray() { readLock(); NodeImpl[] array = new NodeImpl[size]; if (garbageSize == 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock block = blocks[i]; System.arraycopy(block.backingArray, 0, array, block.offset, block.nodeLength); } } else { NodeStoreIterator itr = iterator(); int offset = 0; while (itr.hasNext()) { NodeImpl n = itr.next(); array[offset++] = n; } } readUnlock(); return array; } NodeStore();  NodeStore(final EdgeStore edgeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); }
NodeStore implements Collection<Node>, NodeIterable { @Override public NodeImpl[] toArray() { readLock(); NodeImpl[] array = new NodeImpl[size]; if (garbageSize == 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock block = blocks[i]; System.arraycopy(block.backingArray, 0, array, block.offset, block.nodeLength); } } else { NodeStoreIterator itr = iterator(); int offset = 0; while (itr.hasNext()) { NodeImpl n = itr.next(); array[offset++] = n; } } readUnlock(); return array; } NodeStore();  NodeStore(final EdgeStore edgeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); NodeImpl get(final int id); NodeImpl get(final Object id); @Override void clear(); @Override int size(); @Override boolean isEmpty(); @Override NodeStoreIterator iterator(); @Override NodeImpl[] toArray(); @Override T[] toArray(T[] array); @Override Collection<Node> toCollection(); @Override boolean add(final Node n); @Override boolean remove(final Object o); @Override boolean contains(final Object o); boolean containsId(final Object id); @Override boolean containsAll(final Collection<?> c); @Override boolean addAll(final Collection<? extends Node> c); @Override boolean removeAll(final Collection<?> c); @Override boolean retainAll(final Collection<?> c); int deepHashCode(); boolean deepEquals(NodeStore obj); @Override void doBreak(); }
NodeStore implements Collection<Node>, NodeIterable { @Override public NodeImpl[] toArray() { readLock(); NodeImpl[] array = new NodeImpl[size]; if (garbageSize == 0) { for (int i = 0; i < blocksCount; i++) { NodeBlock block = blocks[i]; System.arraycopy(block.backingArray, 0, array, block.offset, block.nodeLength); } } else { NodeStoreIterator itr = iterator(); int offset = 0; while (itr.hasNext()) { NodeImpl n = itr.next(); array[offset++] = n; } } readUnlock(); return array; } NodeStore();  NodeStore(final EdgeStore edgeStore, final GraphLock lock, final GraphViewStore viewStore, final GraphVersion graphVersion); NodeImpl get(final int id); NodeImpl get(final Object id); @Override void clear(); @Override int size(); @Override boolean isEmpty(); @Override NodeStoreIterator iterator(); @Override NodeImpl[] toArray(); @Override T[] toArray(T[] array); @Override Collection<Node> toCollection(); @Override boolean add(final Node n); @Override boolean remove(final Object o); @Override boolean contains(final Object o); boolean containsId(final Object id); @Override boolean containsAll(final Collection<?> c); @Override boolean addAll(final Collection<? extends Node> c); @Override boolean removeAll(final Collection<?> c); @Override boolean retainAll(final Collection<?> c); int deepHashCode(); boolean deepEquals(NodeStore obj); @Override void doBreak();  }