org.apache.commons.collections

Class TreeBag

Implemented Interfaces:
Bag, Collection, Bag, SortedBag

public class TreeBag
extends DefaultMapBag
implements SortedBag

A Bag that is backed by a TreeMap. Order will be maintained among the unique representative members.
Version:
$Revision: 1.13 $ $Date: 2004/02/18 01:15:42 $
Author:
Chuck Burdick
Since:
Commons Collections 2.0

Constructor Summary

TreeBag()
Constructs an empty TreeBag.
TreeBag(Collection coll)
Constructs a Bag containing all the members of the given collection.
TreeBag(Comparator comparator)
Constructs an empty Bag that maintains order on its unique representative members according to the given Comparator.

Method Summary

Comparator
comparator()
Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
Object
first()
Returns the first (lowest) member.
Object
last()
Returns the last (highest) member.

Methods inherited from class org.apache.commons.collections.DefaultMapBag

add, add, addAll, calcTotalSize, clear, contains, containsAll, containsAll, equals, getCount, getMap, hashCode, isEmpty, iterator, remove, remove, removeAll, retainAll, retainAll, setMap, size, toArray, toArray, toString, uniqueSet

Constructor Details

TreeBag

public TreeBag()
Constructs an empty TreeBag.

TreeBag

public TreeBag(Collection coll)
Constructs a Bag containing all the members of the given collection.
Parameters:
coll - the collection to copy into the bag

TreeBag

public TreeBag(Comparator comparator)
Constructs an empty Bag that maintains order on its unique representative members according to the given Comparator.
Parameters:
comparator - the comparator to use

Method Details

comparator

public Comparator comparator()
Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.
Specified by:
comparator in interface SortedBag
Returns:
the comparator in use, or null if natural ordering

first

public Object first()
Returns the first (lowest) member.
Specified by:
first in interface SortedBag
Returns:
the first element in the sorted bag

last

public Object last()
Returns the last (highest) member.
Specified by:
last in interface SortedBag
Returns:
the last element in the sorted bag

Copyright © 2001-2006 Apache Software Foundation. All Rights Reserved.