@@ -0,0 +1,2031 @@
+/*%0A * Copyright 2015 Real Logic Ltd.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage uk.co.real_logic.agrona.collections;%0A%0Aimport java.util.AbstractCollection;%0Aimport java.util.Collection;%0Aimport java.util.Iterator;%0Aimport java.util.function.Function;%0A%0A/**%0A * An unmodifiable view of a collection that maps each element in an underlying%0A * collection into a view.%0A *%0A * @param %3CV%3E The type of the view.%0A * @param %3CE%3E The type of the underlying element.%0A */%0Apublic class UnmodifiableCollectionView%3CV, E%3E extends AbstractCollection%3CV%3E%0A%7B%0A    private final ReusableIterator iterator = new ReusableIterator();%0A    private final Function%3CE, V%3E viewer;%0A    private final Collection%3CE%3E elements;%0A%0A    public UnmodifiableCollectionView(final Function%3CE, V%3E viewer, final Collection%3CE%3E elements)%0A    %7B%0A        this.viewer = viewer;%0A        this.elements = elements;%0A    %7D%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     */%0A    public int size()%0A    %7B%0A        return elements.size();%0A    %7D%0A%0A    /**%0A     * %7B@inheritDoc%7D%0A     */%0A    public Iterator%3CV%3E iterator()%0A    %7B%0A        return iterator.reset();%0A    %7D%0A%0A    private class ReusableIterator implements Iterator%3CV%3E%0A    %7B%0A        private Iterator%3CE%3E delegate;%0A%0A        public boolean hasNext()%0A        %7B%0A            return delegate.hasNext();%0A        %7D%0A%0A        public V next()%0A        %7B%0A            return viewer.apply(delegate.next());%0A        %7D%0A%0A        private ReusableIterator reset()%0A        %7B%0A            delegate = elements.iterator();%0A            return this;%0A        %7D%0A    %7D%0A%7D%0A

add an UnmodifiableCollectionView