All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.osgi.internal.serviceregistry.ShrinkableEntrySetValueCollection Maven / Gradle / Ivy

There is a newer version: 1.9.22.1
Show newest version
/*******************************************************************************
 * Copyright (c) 2010, 2016 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.osgi.internal.serviceregistry;

import java.util.*;

public class ShrinkableEntrySetValueCollection extends AbstractCollection implements Collection {
	private final Set> entrySet;

	public ShrinkableEntrySetValueCollection(Set> e) {
		if (e == null) {
			throw new NullPointerException();
		}
		entrySet = e;
	}

	@Override
	public void clear() {
		entrySet.clear();
	}

	@Override
	public boolean isEmpty() {
		return entrySet.isEmpty();
	}

	@Override
	public Iterator iterator() {
		return new ValueIterator<>(entrySet.iterator());
	}

	@Override
	public int size() {
		return entrySet.size();
	}

	/**
	 * Iterator over the values of the entry set.
	 */
	static private final class ValueIterator implements Iterator {
		private final Iterator> iter;

		ValueIterator(Iterator> i) {
			iter = i;
		}

		@Override
		public boolean hasNext() {
			return iter.hasNext();
		}

		@Override
		public E next() {
			final Map.Entry entry = iter.next();
			return entry.getValue();
		}

		@Override
		public void remove() {
			iter.remove();
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy