class SetFromMap<E> extends AbstractSet<E> implements ChronicleSet<E> {

    private final ChronicleMap<E, DummyValue> m;  // The backing map
    private transient Set<E> s;       // Its keySet

    SetFromMap(VanillaChronicleMap<E, DummyValue, ?> map) {
        m = map;
        map.chronicleSet = this;
        s = map.keySet();
    }

    public void clear() {
        throwExceptionIfClosed();

        m.clear();
    }

    public int size() {
        throwExceptionIfClosed();

        return m.size();
    }

    public boolean isEmpty() {
        throwExceptionIfClosed();

        return m.isEmpty();
    }

    public boolean contains(Object o) {
        throwExceptionIfClosed();

        return m.containsKey(o);
    }

    public boolean remove(Object o) {
        throwExceptionIfClosed();

        return m.remove(o, DUMMY_VALUE);
    }

    public boolean add(E e) {
        throwExceptionIfClosed();

        return m.putIfAbsent(e, DUMMY_VALUE) == null;
    }

    @NotNull
    public Iterator<E> iterator() {
        throwExceptionIfClosed();

        return s.iterator();
    }

    public Object[] toArray() {
        throwExceptionIfClosed();

        return s.toArray();
    }

    public <T> T[] toArray(T[] a) {
        return s.toArray(a);
    }

    public String toString() {
        return s.toString();
    }

    @NotNull
    @Override
    public String toIdentityString() {<FILL_FUNCTION_BODY>}

    public int hashCode() {
        throwExceptionIfClosed();

        return s.hashCode();
    }

    public boolean equals(Object o) {
        throwExceptionIfClosed();

        return o == this || s.equals(o);
    }

    public boolean containsAll(@NotNull Collection<?> c) {
        throwExceptionIfClosed();

        return s.containsAll(c);
    }

    public boolean removeAll(@NotNull Collection<?> c) {
        throwExceptionIfClosed();

        return s.removeAll(c);
    }

    public boolean retainAll(@NotNull Collection<?> c) {
        throwExceptionIfClosed();

        return s.retainAll(c);
    }
    // addAll is the only inherited implementation

    @Override
    public long longSize() {
        throwExceptionIfClosed();

        return m.longSize();
    }

    @Override
    public long offHeapMemoryUsed() {
        throwExceptionIfClosed();

        return m.offHeapMemoryUsed();
    }

    @Override
    public Class<E> keyClass() {
        throwExceptionIfClosed();

        return m.keyClass();
    }

    @Override
    public Type keyType() {
        throwExceptionIfClosed();

        return m.keyType();
    }

    // TODO test queryContext methods

    @NotNull
    @Override
    public ExternalSetQueryContext<E, ?> queryContext(E key) {
        //noinspection unchecked
        return (ExternalSetQueryContext<E, ?>) m.queryContext(key);
    }

    @NotNull
    @Override
    public ExternalSetQueryContext<E, ?> queryContext(Data<E> key) {
        //noinspection unchecked
        return (ExternalSetQueryContext<E, ?>) m.queryContext(key);
    }

    @NotNull
    @Override
    public ExternalSetQueryContext<E, ?> queryContext(BytesStore keyBytes, long offset, long size) {
        //noinspection unchecked
        return (ExternalSetQueryContext<E, ?>) m.queryContext(keyBytes, offset, size);
    }

    @Override
    public SetSegmentContext<E, ?> segmentContext(int segmentIndex) {
        // TODO
        throw new UnsupportedOperationException();
    }

    @Override
    public int segments() {
        throwExceptionIfClosed();

        return m.segments();
    }

    // TODO test forEach methods

    @Override
    public boolean forEachEntryWhile(Predicate<? super SetEntry<E>> predicate) {
        throwExceptionIfClosed();

        Objects.requireNonNull(predicate);
        return m.forEachEntryWhile(e -> predicate.test(((SetEntry<E>) e)));
    }

    @Override
    public void forEachEntry(Consumer<? super SetEntry<E>> action) {
        throwExceptionIfClosed();

        Objects.requireNonNull(action);
        m.forEachEntry(e -> action.accept(((SetEntry<E>) e)));
    }

    @Override
    public File file() {
        throwExceptionIfClosed();

        return m.file();
    }

    @Override
    public String name() {
        throwExceptionIfClosed();

        return m.name();
    }

    @Override
    public void close() {
        m.close();
    }

    @Override
    public boolean isOpen() {
        throwExceptionIfClosed();

        return m.isOpen();
    }
}

        throwExceptionIfClosed();

        return "ChronicleSet{" +
                "name=" + name() +
                ", file=" + file() +
                ", identityHashCode=" + System.identityHashCode(this) +
                "}";
    
<methods>public boolean equals(java.lang.Object) ,public int hashCode() ,public boolean removeAll(Collection<?>) <variables>