    All Packages  Class Hierarchy  This Package  Previous  Next  Index

# Interface collections.Bag

public interface interface Bag
extends Collection

Bags are collections supporting multiple occurrences of elements.

##

adding(Object)
  Construct a new Bag that is a clone of self except that it includes indicated element.
addingIfAbsent(Object)
  Construct a new Collection that is a clone of self except that it adds the indicated element if not already present.

##

adding

     public abstract Bag adding(Object element) throws IllegalElementException

  Construct a new Bag that is a clone of self except that it includes indicated element. This can be used to create a series of Bag, each differing from the other only in that they contain additional elements.

  Parameters:
    the - element to add to the new Bag
  Returns:
    the new Bag c, with the sameStructure as this except that c.occurrencesOf(element) == occurrencesOf(element)+1
  Throws: IllegalElementException
    if !canInclude(element)

addingIfAbsent

     public abstract Bag addingIfAbsent(Object element) throws IllegalElementException

  Construct a new Collection that is a clone of self except that it adds the indicated element if not already present. This can be used to create a series of collections, each differing from the other only in that they contain additional elements.

  Parameters:
    element - the element to include in the new collection
  Returns:
    a new collection c, with the sameStructure as this, except that c.occurrencesOf(element) = min(1, occurrencesOfElement)
  Throws: IllegalElementException
    if !canInclude(element)

    All Packages  Class Hierarchy  This Package  Previous  Next  Index