Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## umontreal.iro.lecuyer.collections
Class TransformingCollection<OE,IE>

    java.lang.Object
      java.util.AbstractCollection<OE>
          umontreal.iro.lecuyer.collections.TransformingCollection<OE,IE>

Type Parameters:
  `OE` - the outer type of the elements.
  `IE` - the inner type of the elements.

All Implemented Interfaces:
  Iterable<OE>, Collection<OE>

Direct Known Subclasses:
  TransformingList, TransformingSet

    public abstract class TransformingCollection<OE,IE>

extends AbstractCollection<OE>

Represents a collection that dynamically transforms the elements of another collection. This abstract class defines a collection containing an inner collection of elements of a certain type, and provides facilities to convert these inner elements to outer elements of another type. A concrete subclass simply needs to implement the `convertFromInnerType(IE)` and `convertToInnerType(OE)` methods for converting between the inner and the outer types.

It is strongly recommended that the mapping established by the conversion methods be one-to-one, i.e., an element in the inner collection corresponds to a single element in the outer collection. Otherwise, the size of the outer collection might be incorrect, and the iterator may unexpectedly give the same elements multiple times. Also, `null` should always correspond to `null`.

Constructor Summary
`TransformingCollection(Collection<IE> innerCollection)` Constructs a new transforming collection mapping the elements of the inner collection `innerCollection`.

Method Summary
`boolean` | `add(OE o)`
`void` | `clear()`
`boolean` | `contains(Object o)`
`abstract OE` | `convertFromInnerType(IE e)` Converts an element in the inner collection to an element of the outer type.
`abstract IE` | `convertToInnerType(OE e)` Converts an element of the outer type to an element of the inner collection.
`Collection<IE>` | `getInnerCollection()` Returns the inner collection.
`boolean` | `isEmpty()`
`Iterator<OE>` | `iterator()`
`boolean` | `remove(Object o)`
`int` | `size()`

Methods inherited from class java.util.AbstractCollection
`addAll, containsAll, removeAll, retainAll, toArray, toArray, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface java.util.Collection
`equals, hashCode`

Constructor Detail

### TransformingCollection

    public TransformingCollection(Collection<IE> innerCollection)

  Constructs a new transforming collection mapping the elements of the inner collection `innerCollection`.

  Parameters:
    `innerCollection` - the inner collection.
  Throws:
    `NullPointerException` - if `innerCollection` is `null`.

Method Detail

### getInnerCollection

    public Collection<IE> getInnerCollection()

  Returns the inner collection.

  Returns:
    the inner collection.

### convertFromInnerType

    public abstract OE convertFromInnerType(IE e)

  Converts an element in the inner collection to an element of the outer type.

  Parameters:
    `e` - the inner element.
  Returns:
    the outer element.

### convertToInnerType

    public abstract IE convertToInnerType(OE e)

  Converts an element of the outer type to an element of the inner collection.

  Parameters:
    `e` - the outer element.
  Returns:
    the inner element.

### iterator

    public Iterator<OE> iterator()

  Specified by:
    `iterator` in interface `Iterable<OE>`
  Specified by:
    `iterator` in interface `Collection<OE>`
  Specified by:
    `iterator` in class `AbstractCollection<OE>`

### size

    public int size()

  Specified by:
    `size` in interface `Collection<OE>`
  Specified by:
    `size` in class `AbstractCollection<OE>`

### add

    public boolean add(OE o)

  Specified by:
    `add` in interface `Collection<OE>`
  Overrides:
    `add` in class `AbstractCollection<OE>`

### clear

    public void clear()

  Specified by:
    `clear` in interface `Collection<OE>`
  Overrides:
    `clear` in class `AbstractCollection<OE>`

### contains

    public boolean contains(Object o)

  Specified by:
    `contains` in interface `Collection<OE>`
  Overrides:
    `contains` in class `AbstractCollection<OE>`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` in interface `Collection<OE>`
  Overrides:
    `isEmpty` in class `AbstractCollection<OE>`

### remove

    public boolean remove(Object o)

  Specified by:
    `remove` in interface `Collection<OE>`
  Overrides:
    `remove` in class `AbstractCollection<OE>`

Overview | Package | Class | Tree | Deprecated | Index | Help
| ContactCenters V. 0.9.9.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

To submit a bug or ask questions, send an e-mail to Richard Simard.