Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
commons-collections4-4.2-sources.jar - Apache Commons Collections
commons-collections4-4.2-sources.jar is the source JAR file for Apache Commons Collections 4.2, which
provides additional collection handling functionalities on top of JDK library.
JAR File Size and Download Location:
JAR name: commons-collections4-4.2-sources.jar Target JDK version: 1.7 Dependency: None File size: 708,599 bytes Release date: 08-Jul-2018 Download: Apache Commons Collections
✍: FYIcenter.com
⏎ org/apache/commons/collections4/set/MapBackedSet.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.commons.collections4.set; import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.Map; import java.util.Set; /** * Decorates a <code>Map</code> to obtain <code>Set</code> behaviour. * <p> * This class is used to create a <code>Set</code> with the same properties as * the key set of any map. Thus, a ReferenceSet can be created by wrapping a * <code>ReferenceMap</code> in an instance of this class. * <p> * Most map implementation can be used to create a set by passing in dummy values. * Exceptions include <code>BidiMap</code> implementations, as they require unique values. * * @param <E> the type of the elements in this set * @param <V> the dummy value type in this map * @since 3.1 */ public final class MapBackedSet<E, V> implements Set<E>, Serializable { /** Serialization version */ private static final long serialVersionUID = 6723912213766056587L; /** The map being used as the backing store */ private final Map<E, ? super V> map; /** The dummyValue to use */ private final V dummyValue; /** * Factory method to create a set from a map. * * @param <E> the element type * @param <V> the dummy value type in the map * @param map the map to decorate, must not be null * @return a new map backed set * @throws NullPointerException if map is null * @since 4.0 */ public static <E, V> MapBackedSet<E, V> mapBackedSet(final Map<E, ? super V> map) { return mapBackedSet(map, null); } /** * Factory method to create a set from a map. * * @param <E> the element type * @param <V> the dummy value type in the map * @param map the map to decorate, must not be null * @param dummyValue the dummy value to use * @return a new map backed set * @throws NullPointerException if map is null * @since 4.0 */ public static <E, V> MapBackedSet<E, V> mapBackedSet(final Map<E, ? super V> map, final V dummyValue) { return new MapBackedSet<>(map, dummyValue); } //----------------------------------------------------------------------- /** * Constructor that wraps (not copies). * * @param map the map to decorate, must not be null * @param dummyValue the dummy value to use * @throws NullPointerException if map is null */ private MapBackedSet(final Map<E, ? super V> map, final V dummyValue) { super(); if (map == null) { throw new NullPointerException("The map must not be null"); } this.map = map; this.dummyValue = dummyValue; } //----------------------------------------------------------------------- @Override public int size() { return map.size(); } @Override public boolean isEmpty() { return map.isEmpty(); } @Override public Iterator<E> iterator() { return map.keySet().iterator(); } @Override public boolean contains(final Object obj) { return map.containsKey(obj); } @Override public boolean containsAll(final Collection<?> coll) { return map.keySet().containsAll(coll); } @Override public boolean add(final E obj) { final int size = map.size(); map.put(obj, dummyValue); return map.size() != size; } @Override public boolean addAll(final Collection<? extends E> coll) { final int size = map.size(); for (final E e : coll) { map.put(e, dummyValue); } return map.size() != size; } @Override public boolean remove(final Object obj) { final int size = map.size(); map.remove(obj); return map.size() != size; } @Override public boolean removeAll(final Collection<?> coll) { return map.keySet().removeAll(coll); } @Override public boolean retainAll(final Collection<?> coll) { return map.keySet().retainAll(coll); } @Override public void clear() { map.clear(); } @Override public Object[] toArray() { return map.keySet().toArray(); } @Override public <T> T[] toArray(final T[] array) { return map.keySet().toArray(array); } @Override public boolean equals(final Object obj) { return map.keySet().equals(obj); } @Override public int hashCode() { return map.keySet().hashCode(); } }
⏎ org/apache/commons/collections4/set/MapBackedSet.java
Or download all of them as a single archive file:
File name: commons-collections4-4.2-sources.jar File size: 708599 bytes Release date: 2018-07-08 Download
⇒ Download and Install commons-collections4-4.1-bin.zip
⇐ What Is commons-collections4-4.2.jar
2023-03-28, 41926👍, 0💬
Popular Posts:
How to display types defined in an XML Schema file with the xs\QueryXS.java provided in the Apache X...
Where Can I see Java Source Code files for Xerces Java 2.11.2? Here are Java Source Code files for X...
What Is activation.jar? I heard it's related to JAF (JavaBeans Activation Framework) 1.1? The if you...
If you are a Java developer, it is very often that you need to use some 3rd party libraries to perfo...
What Is log4j-1.2.15.jar? I got the JAR file from apache-log4j-1.2.15.zip. log4j-1.2.15.jar is the v...