public class

TreeBag

extends DefaultMapBag
implements SortedBag
java.lang.Object
   ↳ org.apache.commons.collections.DefaultMapBag
     ↳ org.apache.commons.collections.TreeBag

This class is deprecated.
Moved to bag subpackage and rewritten internally. Due to be removed in v4.0.

Class Overview

A Bag that is backed by a TreeMap. Order will be maintained among the unique representative members.

Summary

Public Constructors
TreeBag()
Constructs an empty TreeBag.
TreeBag(Comparator comparator)
Constructs an empty Bag that maintains order on its unique representative members according to the given Comparator.
TreeBag(Collection coll)
Constructs a Bag containing all the members of the given collection.
Public Methods
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.
[Expand]
Inherited Methods
From class org.apache.commons.collections.DefaultMapBag
From class java.lang.Object
From interface java.lang.Iterable
From interface java.util.Collection
From interface org.apache.commons.collections.Bag
From interface org.apache.commons.collections.SortedBag

Public Constructors

public TreeBag ()

Constructs an empty 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

public TreeBag (Collection coll)

Constructs a Bag containing all the members of the given collection.

Parameters
coll the collection to copy into the bag

Public Methods

public Comparator comparator ()

Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering.

Returns
  • the comparator in use, or null if natural ordering

public Object first ()

Returns the first (lowest) member.

Returns
  • the first element in the sorted bag

public Object last ()

Returns the last (highest) member.

Returns
  • the last element in the sorted bag