@Override
    public Object[] toArray() {
        Object[] result = new Object[size()];
        Iterator<T> iter = iterator();
        int i = 0;
        while (iter.hasNext()) {
            result[i++] = iter.next();
        }
        return result;
    }
@Test
    public void testToArray() {
        SnapshotRegistry registry = new SnapshotRegistry(new LogContext());
        TimelineHashSet<String> set = new TimelineHashSet<>(registry, 1);
        set.add("z");
        assertArrayEquals(new String[] {"z"}, set.toArray());
        assertArrayEquals(new String[] {"z", null}, set.toArray(new String[2]));
        assertArrayEquals(new String[] {"z"}, set.toArray(new String[0]));
    }