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
This commit is contained in:
Michael Smith 2002-03-25 05:50:57 +00:00
parent e25229d271
commit 80ea89fd05
3 changed files with 15 additions and 15 deletions

View File

@ -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 <a href="mas@apache.org">Michael A. Smith</a>
**/
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;

View File

@ -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());
}

View File

@ -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());
}