From 80ea89fd05deb7cf51ba37f8b6d3f4758bfb7c90 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 25 Mar 2002 05:50:57 +0000 Subject: [PATCH] Renamed AbstractBag to DefaultMapBag. The implementation is more of a "default map based implementation" and differs in design from the AbstractSet, AbstractMap classes which do not make assumptions about how they might be implemented. To be consistent with JDK AbstractX collections, an AbstractBag class should just be providing default implementations that could be used regardless of underlying storage mechanism. For example, the add(Object) method would call the abstract add(Object,int) method passing the object and 1. Since this implementation assumes a Map based storage for the Bag, it does not follow the AbstractX pattern, and thus has been renamed. There is still room for future addition of an AbstractBag that does not assume a storage data structure. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130675 13f79535-47bb-0310-9956-ffa450edef68 --- .../{AbstractBag.java => DefaultMapBag.java} | 14 +++++++------- .../org/apache/commons/collections/HashBag.java | 8 ++++---- .../org/apache/commons/collections/TreeBag.java | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) rename src/java/org/apache/commons/collections/{AbstractBag.java => DefaultMapBag.java} (96%) diff --git a/src/java/org/apache/commons/collections/AbstractBag.java b/src/java/org/apache/commons/collections/DefaultMapBag.java similarity index 96% rename from src/java/org/apache/commons/collections/AbstractBag.java rename to src/java/org/apache/commons/collections/DefaultMapBag.java index f18ae9167..baa03f20d 100644 --- a/src/java/org/apache/commons/collections/AbstractBag.java +++ b/src/java/org/apache/commons/collections/DefaultMapBag.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/Attic/AbstractBag.java,v 1.5 2002/03/13 05:40:30 mas Exp $ - * $Revision: 1.5 $ - * $Date: 2002/03/13 05:40:30 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/DefaultMapBag.java,v 1.1 2002/03/25 05:50:57 mas Exp $ + * $Revision: 1.1 $ + * $Date: 2002/03/25 05:50:57 $ * * ==================================================================== * @@ -81,7 +81,7 @@ import java.util.Set; * @author Chuck Burdick * @author Michael A. Smith **/ -public abstract class AbstractBag implements Bag { +public abstract class DefaultMapBag implements Bag { private Map _map = null; private int _total = 0; private int _mods = 0; @@ -146,7 +146,7 @@ public abstract class AbstractBag implements Bag { public boolean equals(Object o) { return (o == this || (o != null && o.getClass().equals(this.getClass()) && - ((AbstractBag)o)._map.equals(this._map))); + ((DefaultMapBag)o)._map.equals(this._map))); } public int hashCode() { @@ -162,12 +162,12 @@ public abstract class AbstractBag implements Bag { } private class BagIterator implements Iterator { - private AbstractBag _parent = null; + private DefaultMapBag _parent = null; private Iterator _support = null; private Object _current = null; private int _mods = 0; - public BagIterator(AbstractBag parent, Iterator support) { + public BagIterator(DefaultMapBag parent, Iterator support) { _parent = parent; _support = support; _current = null; diff --git a/src/java/org/apache/commons/collections/HashBag.java b/src/java/org/apache/commons/collections/HashBag.java index 73aca98fd..48134c907 100644 --- a/src/java/org/apache/commons/collections/HashBag.java +++ b/src/java/org/apache/commons/collections/HashBag.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/HashBag.java,v 1.3 2002/03/13 05:40:30 mas Exp $ - * $Revision: 1.3 $ - * $Date: 2002/03/13 05:40:30 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/HashBag.java,v 1.4 2002/03/25 05:50:57 mas Exp $ + * $Revision: 1.4 $ + * $Date: 2002/03/25 05:50:57 $ * * ==================================================================== * @@ -70,7 +70,7 @@ import java.util.HashMap; * * @author Chuck Burdick **/ -public class HashBag extends AbstractBag implements Bag { +public class HashBag extends DefaultMapBag implements Bag { public HashBag() { setMap(new HashMap()); } diff --git a/src/java/org/apache/commons/collections/TreeBag.java b/src/java/org/apache/commons/collections/TreeBag.java index 5b8960a72..a314a095f 100644 --- a/src/java/org/apache/commons/collections/TreeBag.java +++ b/src/java/org/apache/commons/collections/TreeBag.java @@ -1,7 +1,7 @@ /* - * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/TreeBag.java,v 1.3 2002/03/13 05:40:31 mas Exp $ - * $Revision: 1.3 $ - * $Date: 2002/03/13 05:40:31 $ + * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/TreeBag.java,v 1.4 2002/03/25 05:50:57 mas Exp $ + * $Revision: 1.4 $ + * $Date: 2002/03/25 05:50:57 $ * * ==================================================================== * @@ -73,7 +73,7 @@ import java.util.TreeMap; * * @author Chuck Burdick **/ -public class TreeBag extends AbstractBag implements SortedBag, Bag { +public class TreeBag extends DefaultMapBag implements SortedBag, Bag { public TreeBag() { setMap(new TreeMap()); }