public HashBag(Collection coll) {
this();
addAll(coll);
}
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
super.doWriteObject(out);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
super.doReadObject(new HashMap(), in);
}
}
public class TreeBag extends AbstractMapBag implements SortedBag, Serializable
{
private static final long serialVersionUID = -7740146511091606676L;
public TreeBag() {
super(new TreeMap());
}
public TreeBag(Comparator comparator) {
super(new TreeMap(comparator));
}
public TreeBag(Collection coll) {
this();
addAll(coll);
}
public Object first() {
return ((SortedMap) getMap()).firstKey();
}
public Object last() {
return ((SortedMap) getMap()).lastKey();
}
public Comparator comparator() {
return ((SortedMap) getMap()).comparator();
}
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(comparator());
super.doWriteObject(out);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
Comparator comp = (Comparator) in.readObject();
super.doReadObject(new TreeMap(comp), in);
}
}
public class PredicatedBag extends PredicatedCollection implements Bag
{
private static final long serialVersionUID = -2575833140344736876L;
public static Bag decorate(Bag bag, Predicate predicate) {
return new PredicatedBag(bag, predicate);
}
protected PredicatedBag(Bag bag, Predicate predicate) {
super(bag, predicate);
}
protected Bag getBag() {
return (Bag) getCollection();
}
public boolean add(Object object, int count) {
validate(object);
return getBag().add(object, count);
}
public boolean remove(Object object, int count) {
return getBag().remove(object, count);
}
public Set uniqueSet() {
return getBag().uniqueSet();
}
public int getCount(Object object) {
return getBag().getCount(object);
}
}
public class PredicatedSortedBag extends PredicatedBag implements SortedBag
{
private static final long serialVersionUID = 3448581314086406616L;
public static SortedBag decorate(SortedBag bag, Predicate predicate) {
return new PredicatedSortedBag(bag, predicate);
}
protected PredicatedSortedBag(SortedBag bag, Predicate predicate) {
super(bag, predicate);
}
protected SortedBag getSortedBag() {
return (SortedBag) getCollection();
}
public Object first() {
return getSortedBag().first();
}
public Object last() {
return ge
|