xxl.collections
Interface Bag

All Known Implementing Classes:
AbstractBag

public abstract interface Bag

The interface Bag provides a data type similar to MultiSets. The sequence of elements delivered by a cursor has no predefined order. However, a subclass may define such an order.


Field Summary
static Function FACTORY_METHOD
          A factory method to create a default Bag.
 
Method Summary
 void clear()
          Removes all elements from the bag such that size will be zero thereafter.
 void close()
          Releases any resources needed so far.
 Cursor cursor()
          Creates a cursor to iterate over the elements of the bag.
 void insert(java.lang.Object object)
          Insert an element into the bag.
 void insertAll(java.util.Iterator objects)
          Insert a bunch of elements into the bag.
 int size()
          Returns the number of elements stored in this bag.
 

Field Detail

FACTORY_METHOD

public static final Function FACTORY_METHOD
A factory method to create a default Bag. Each implementation of Bag should have a field FACTORY_METHOD which is a factory method that implements three variants of invoke()
Method Detail

clear

public void clear()
Removes all elements from the bag such that size will be zero thereafter.

close

public void close()
Releases any resources needed so far. The bag is reopened implicitely by consecutive calls to its methods, if needed.

cursor

public Cursor cursor()
Creates a cursor to iterate over the elements of the bag.

insert

public void insert(java.lang.Object object)
Insert an element into the bag. This method does not perform any kind of duplicate detection.
Parameters:
object - the element to be inserted.

insertAll

public void insertAll(java.util.Iterator objects)
Insert a bunch of elements into the bag. This method does not perform any kind of duplicate detection.
Parameters:
objects - the iterator providing the elements to be inserted.

size

public int size()
Returns the number of elements stored in this bag.