You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/07/11 17:53:55 UTC
[07/18] commons-collections git commit: to ease maintenance,
removed all unreleased classes from the 1.x branch
to ease maintenance, removed all unreleased classes from the 1.x branch
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/branches/collections_1_x_branch@130591 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/commons-collections/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-collections/commit/03ef3163
Tree: http://git-wip-us.apache.org/repos/asf/commons-collections/tree/03ef3163
Diff: http://git-wip-us.apache.org/repos/asf/commons-collections/diff/03ef3163
Branch: refs/heads/collections_1_x_branch
Commit: 03ef31630037d07ad1e89c7fe7fb98e5716bf0db
Parents: 6a2c9bf
Author: Morgan James Delagrange <mo...@apache.org>
Authored: Tue Feb 26 00:58:29 2002 +0000
Committer: Morgan James Delagrange <mo...@apache.org>
Committed: Tue Feb 26 00:58:29 2002 +0000
----------------------------------------------------------------------
.../apache/commons/collections/AbstractBag.java | 335 ---
.../org/apache/commons/collections/Bag.java | 181 --
.../commons/collections/DoubleOrderedMap.java | 2046 -------------
.../org/apache/commons/collections/HashBag.java | 89 -
.../apache/commons/collections/ListUtils.java | 119 -
.../commons/collections/MultiHashMap.java | 206 --
.../apache/commons/collections/MultiMap.java | 80 -
.../commons/collections/SequencedHashMap.java | 888 ------
.../commons/collections/SingletonIterator.java | 98 -
.../apache/commons/collections/SortedBag.java | 88 -
.../org/apache/commons/collections/TreeBag.java | 117 -
.../org/apache/commons/collections/TestAll.java | 14 +-
.../org/apache/commons/collections/TestBag.java | 251 --
.../collections/TestDoubleOrderedMap.java | 2798 ------------------
.../apache/commons/collections/TestHashBag.java | 90 -
.../commons/collections/TestMultiHashMap.java | 226 --
.../collections/TestSequencedHashMap.java | 177 --
.../collections/TestSingletonIterator.java | 112 -
.../apache/commons/collections/TestTreeBag.java | 119 -
19 files changed, 4 insertions(+), 8030 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/03ef3163/src/java/org/apache/commons/collections/AbstractBag.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/AbstractBag.java b/src/java/org/apache/commons/collections/AbstractBag.java
deleted file mode 100644
index 864aeee..0000000
--- a/src/java/org/apache/commons/collections/AbstractBag.java
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/Attic/AbstractBag.java,v 1.2 2002/02/10 08:07:42 jstrachan Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/10 08:07:42 $
- *
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Commons", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.commons.collections;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-/**
- * This class provides a skeletal implementation of the {@link Bag}
- * interface to minimize the effort required for target implementations.
- *
- * @author Chuck Burdick
- **/
-public abstract class AbstractBag implements Bag {
- private Map _map = null;
- private int _total = 0;
- private int _mods = 0;
-
- public boolean add(Object o) {
- return add(o, 1);
- }
-
- public boolean add(Object o, int i) {
- _mods++;
- if (i > 0) {
- int count = (i + getCount(o));
- _map.put(o, new Integer(count));
- _total += i;
- return (getCount(o) == i);
- } else {
- return false;
- }
- }
-
- public boolean addAll(Collection c) {
- boolean changed = false;
- Iterator i = c.iterator();
- while (i.hasNext()) {
- boolean added = add(i.next());
- changed = changed || added;
- }
- return changed;
- }
-
- public void clear() {
- _mods++;
- _map.clear();
- _total = 0;
- }
-
- public boolean contains(Object o) {
- return _map.containsKey(o);
- }
-
- public boolean containsAll(Collection c) {
- return containsAll(new HashBag(c));
- }
-
- /**
- * Returns <code>true</code> if the bag contains all elements in
- * the given collection, respecting cardinality.
- * @see #containsAll(Collection)
- **/
- public boolean containsAll(Bag other) {
- boolean result = true;
- Iterator i = other.uniqueSet().iterator();
- while (i.hasNext()) {
- Object current = i.next();
- boolean contains =
- getCount(current) >= ((Bag)other).getCount(current);
- result = result && contains;
- }
- return result;
- }
-
- public boolean equals(Object o) {
- boolean result = false;
- if (o instanceof AbstractBag) {
- result = _map.equals(((AbstractBag)o).getMap());
- } else if (o instanceof Map) {
- result = _map.equals((Map)o);
- }
- return result;
- }
-
- public int hashCode() {
- return _map.hashCode();
- }
-
- public boolean isEmpty() {
- return _map.isEmpty();
- }
-
- public Iterator iterator() {
- return new BagIterator(this, extractList().iterator());
- }
-
- private class BagIterator implements Iterator {
- private AbstractBag _parent = null;
- private Iterator _support = null;
- private Object _current = null;
- private int _mods = 0;
-
- public BagIterator(AbstractBag parent, Iterator support) {
- _parent = parent;
- _support = support;
- _current = null;
- _mods = parent.modCount();
- }
-
- public boolean hasNext() {
- return _support.hasNext();
- }
-
- public Object next() {
- if (_parent.modCount() != _mods) {
- throw new ConcurrentModificationException();
- }
- _current = _support.next();
- return _current;
- }
-
- public void remove() {
- if (_parent.modCount() != _mods) {
- throw new ConcurrentModificationException();
- }
- _support.remove();
- _parent.remove(_current, 1);
- _mods++;
- }
- }
-
- public boolean remove (Object o) {
- return remove(o, getCount(o));
- }
-
- public boolean remove (Object o, int i) {
- _mods++;
- boolean result = false;
- int count = getCount(o);
- if (count > i) {
- _map.put(o, new Integer(count - i));
- result = true;
- _total -= i;
- } else {
- result = uniqueSet().remove(o);
- _total -= count;
- }
- return result;
- }
-
- public boolean removeAll(Collection c) {
- boolean result = false;
- if (c != null) {
- Iterator i = c.iterator();
- while (i.hasNext()) {
- boolean changed = remove(i.next(), 1);
- result = result || changed;
- }
- }
- return result;
- }
-
- public boolean retainAll(Collection c) {
- return retainAll(new HashBag(c));
- }
-
- /**
- * Remove any members of the bag that are not in the given
- * bag, respecting cardinality.
- * @see #retainAll(Collection)
- * @return <code>true</code> if this call changed the collection
- **/
- public boolean retainAll(Bag other) {
- boolean result = false;
- Bag excess = new HashBag();
- Iterator i = uniqueSet().iterator();
- while (i.hasNext()) {
- Object current = i.next();
- int myCount = getCount(current);
- int otherCount = other.getCount(current);
- if (1 <= otherCount && otherCount <= myCount) {
- excess.add(current, myCount - otherCount);
- } else {
- excess.add(current, myCount);
- }
- }
- if (!excess.isEmpty()) {
- result = removeAll(excess);
- }
- return result;
- }
-
- public Object[] toArray() {
- return extractList().toArray();
- }
-
- public Object[] toArray(Object[] a) {
- return extractList().toArray(a);
- }
-
- public int getCount(Object o) {
- int result = 0;
- Integer count = MapUtils.getInteger(_map, o);
- if (count != null) {
- result = count.intValue();
- }
- return result;
- }
-
- public Set uniqueSet() {
- return _map.keySet();
- }
-
- public int size() {
- return _total;
- }
-
- /**
- * Actually walks the bag to make sure the count is correct and
- * resets the running total
- **/
- protected int calcTotalSize() {
- _total = extractList().size();
- return _total;
- }
-
- /**
- * Utility method for implementations to set the map that backs
- * this bag. Not intended for interactive use outside of
- * subclasses.
- **/
- protected void setMap(Map m) {
- _map = m;
- }
-
- /**
- * Utility method for implementations to access the map that backs
- * this bag. Not intended for interactive use outside of
- * subclasses.
- **/
- protected Map getMap() {
- return _map;
- }
-
- /**
- * Create a list for use in iteration, etc.
- **/
- private List extractList() {
- List result = new ArrayList();
- Iterator i = uniqueSet().iterator();
- while (i.hasNext()) {
- Object current = i.next();
- for (int index = 0; index < getCount(current); index++) {
- result.add(current);
- }
- }
- return result;
- }
-
- /**
- * Return number of modifications for iterator
- **/
- private int modCount() {
- return _mods;
- }
-}
-
-
-
http://git-wip-us.apache.org/repos/asf/commons-collections/blob/03ef3163/src/java/org/apache/commons/collections/Bag.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/commons/collections/Bag.java b/src/java/org/apache/commons/collections/Bag.java
deleted file mode 100644
index 560f5d8..0000000
--- a/src/java/org/apache/commons/collections/Bag.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/Bag.java,v 1.2 2002/02/10 08:07:42 jstrachan Exp $
- * $Revision: 1.2 $
- * $Date: 2002/02/10 08:07:42 $
- *
- * ====================================================================
- *
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
- * reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Apache Software Foundation (http://www.apache.org/)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The names "The Jakarta Project", "Commons", and "Apache Software
- * Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
- * permission, please contact apache@apache.org.
- *
- * 5. Products derived from this software may not be called "Apache"
- * nor may "Apache" appear in their names without prior written
- * permission of the Apache Group.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
- * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * <http://www.apache.org/>.
- *
- */
-
-package org.apache.commons.collections;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * A {@link Collection} that keeps a count of its members of the same
- * type, using <code>hashCode</code> to check for equality. Suppose
- * you have a Bag that contains <code>{a, a, b, c}</code>. Calling
- * {@link #getCount} on <code>a</code> would return 2, while calling
- * {@link #uniqueSet} would return <code>{a, b, c}</code>.
- *
- * @author Chuck Burdick
- **/
-public interface Bag extends Collection {
- /**
- * Return the number of occurrences (cardinality) of the given
- * object currently in the bag. If the object does not exist in the
- * bag, return 0.
- **/
- public int getCount(Object o);
-
- /**
- * Add the given object to the bag and keep a count. If the object
- * is already in the {@link #uniqueSet} then increment its count as
- * reported by {@link #getCount}. Otherwise add it to the {@link
- * #uniqueSet} and report its count as 1.
- * @return <code>true</code> if the object was not already in the
- * <code>uniqueSet</code>
- * @see #getCount
- **/
- public boolean add(Object o);
-
- /**
- * Add <code>i</code> copies of the given object to the bag and
- * keep a count.
- * @return <code>true</code> if the object was not already in the
- * <code>uniqueSet</code>
- * @see #add(Object)
- * @see #getCount
- **/
- public boolean add(Object o, int i);
-
- /**
- * Remove all occurrences of the given object from the bag, and do
- * not represent the object in the {@link #uniqueSet}.
- * @see #remove(Object, int)
- * @return <code>true</code> if this call changed the collection
- **/
- public boolean remove(Object o);
-
- /**
- * Remove the given number of occurrences from the bag. If the bag
- * contains less than <code>i</code> occurrences, the item will be
- * removed from the {@link #uniqueSet}.
- * @see #getCount
- * @see #remove(Object)
- * @return <code>true</code> if this call changed the collection
- **/
- public boolean remove(Object o, int i);
-
- /**
- * The {@link Set} of unique members that represent all members in
- * the bag. Uniqueness constraints are the same as those in {@link
- * Set}.
- **/
- public Set uniqueSet();
-
- /**
- * Returns the total number of items in the bag across all types.
- * @see #size
- **/
- public int size();
-
- /**
- * Returns <code>true</code> if the bag contains all elements in
- * the given collection, respecting cardinality. That is, if the
- * given collection <code>C</code> contains <code>n</code> copies
- * of a given object, calling {@link #getCount} on that object must
- * be >= <code>n</code> for all <code>n</code> in <code>C</code>.
- **/
- public boolean containsAll(Collection c);
-
- /**
- * Remove all elements represented in the given collection,
- * respecting cardinality. That is, if the given collection
- * <code>C</code> contains <code>n</code> copies of a given object,
- * the bag will have <code>n</code> fewer copies, assuming the bag
- * had at least <code>n</code> copies to begin with.
- * @return <code>true</code> if this call changed the collection
- **/
- public boolean removeAll(Collection c);
-
- /**
- * Remove any members of the bag that are not in the given
- * collection, respecting cardinality. That is, if the given
- * collection <code>C</code> contains <code>n</code> copies of a
- * given object and the bag has <code>m > n</code> copies, then
- * delete <code>m - n</code> copies from the bag. In addition, if
- * <code>e</code> is an object in the bag but
- * <code>!C.contains(e)</code>, then remove <code>e</code> and any
- * of its copies.
- *
- * @return <code>true</code> if this call changed the collection
- **/
- public boolean retainAll(Collection c);
-
- /**
- * Returns an {@link Iterator} over the entire set of members,
- * including copies due to cardinality. This iterator is fail-fast
- * and will not tolerate concurrent modifications.
- **/
- public Iterator iterator();
-}
-
-
-
-
-