xxl.collections
Class ListBag

java.lang.Object
  |
  +--xxl.collections.AbstractBag
        |
        +--xxl.collections.ListBag

public class ListBag
extends AbstractBag

The class ListBag implements the interface Bag storing elements in a List.


Field Summary
static Function FACTORY_METHOD
          A factory method to create a new ListBag.
protected  java.util.List list
           
 
Fields inherited from class xxl.collections.AbstractBag
FACTORY_METHOD
 
Constructor Summary
ListBag()
          Constructor that instantiates a new LinkedList to create the bag.
ListBag(java.util.Iterator iterator)
          Constructor that instantiates a new LinkedList to create the bag.
ListBag(java.util.List list)
          Constructor for creating a bag backed by a pre-existing list.
 
Method Summary
 void clear()
          Removes all elements from the bag such that size will be zero thereafter.
 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.
 int size()
          Returns the number of elements stored in this bag.
 
Methods inherited from class xxl.collections.AbstractBag
close, insertAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FACTORY_METHOD

public static final Function FACTORY_METHOD
A factory method to create a new ListBag. It may be invoked with or without a given list. (see contract for FACTORY_METHOD in interface Bag)

list

protected java.util.List list
Constructor Detail

ListBag

public ListBag(java.util.List list)
Constructor for creating a bag backed by a pre-existing list.
Parameters:
list - the list to be used by this bag.

ListBag

public ListBag()
Constructor that instantiates a new LinkedList to create the bag.

ListBag

public ListBag(java.util.Iterator iterator)
Constructor that instantiates a new LinkedList to create the bag.
Method Detail

clear

public void clear()
Removes all elements from the bag such that size will be zero thereafter.
Overrides:
clear in class AbstractBag

cursor

public Cursor cursor()
Creates a cursor to iterate over the elements of the bag.
Overrides:
cursor in class AbstractBag

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.
Overrides:
insert in class AbstractBag

size

public int size()
Returns the number of elements stored in this bag.
Overrides:
size in class AbstractBag