jaggregate
Interface ContractibleSequence<E>

Type Parameters:
E - a restriction on the types of elements that may be included in the sequence
All Superinterfaces:
Collection<E>
All Known Implementing Classes:
NaturallySortedCollection, OrderedCollection, SortedCollection

public interface ContractibleSequence<E>
extends Collection<E>

Provides protocol for removing elements from an ordered collection of objects, whose elements can be accessed using external keys.

Version:
$Id: ContractibleSequence.java,v 1.4 2008/05/07 06:00:49 pholser Exp $
Author:
Paul Holser

Method Summary
<R> ContractibleSequence<R>
collect(UnaryFunctor<? super E,? extends R> transformer)
          Evaluates the given transformer for each element of this collection, with the element as the parameter, and answers a new collection containing the results of these evaluations.
 ContractibleSequence<E> reject(UnaryCondition<? super E> discriminator)
          Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer false.
 E removeAt(int index)
          Removes and answers the element at a given position in this sequence.
 E removeFirst()
          Removes and answers the first element of this sequence.
 E removeLast()
          Removes and answers the last element of this sequence.
 ContractibleSequence<E> select(UnaryCondition<? super E> discriminator)
          Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer true.
 
Methods inherited from interface jaggregate.Collection
allSatisfy, anySatisfy, detect, forEachDo, includes, inject, isEmpty, occurrencesOf, rehash, size, toArray, toArray, toBag, toIdentityBag, toIdentitySet, toOrderedCollection, toSet, toSortedCollection, toSortedCollection
 

Method Detail

collect

<R> ContractibleSequence<R> collect(UnaryFunctor<? super E,? extends R> transformer)
Evaluates the given transformer for each element of this collection, with the element as the parameter, and answers a new collection containing the results of these evaluations.

The elements are traversed in the order specified by forEachDo for this collection.

Unless specifically refined, this message is defined to answer an object conforming to the same protocol as this collection.

Specified by:
collect in interface Collection<E>
Type Parameters:
R - return type of the transformer
Parameters:
transformer - the transformer to evaluate
Returns:
a contractible sequence of the transformations

reject

ContractibleSequence<E> reject(UnaryCondition<? super E> discriminator)
Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer false.

For each element of this collection, discriminator is evaluated with the element as the parameter. Each element which causes discriminator to answer false is included in the new collection.

The elements are traversed in the order specified by forEachDo for this collection.

Unless specifically refined, this message is defined to answer an object conforming to the same protocol as this collection. If both this collection and the result maintain an ordering of their elements, the elements of the result will be in the same relative order as the elements of this collection.

Specified by:
reject in interface Collection<E>
Parameters:
discriminator - the discriminator to evaluate
Returns:
a contractible sequence of the rejected elements of this sequence

select

ContractibleSequence<E> select(UnaryCondition<? super E> discriminator)
Answers a new collection which contains only the elements in this collection which cause the given discriminator to answer true.

For each element of this collection, discriminator is evaluated with the element as the parameter. Each element which causes discriminator to answer true is included in the new collection.

The elements are traversed in order specified by forEachDo for this collection.

Unless specifically refined, this message is defined to answer an object conforming to the same protocol as this collection. If both this collection and the result maintain an ordering of their elements, the elements of the result will be in the same relative order as the elements of this collection.

Specified by:
select in interface Collection<E>
Parameters:
discriminator - the discriminator to evaluate
Returns:
a contractible sequence of the selected elements of this sequence

removeAt

E removeAt(int index)
Removes and answers the element at a given position in this sequence.

Parameters:
index - the index at which to remove the element
Returns:
the removed element
Throws:
IndexOutOfBoundsException - if index < 0 or index >= this collection's size

removeFirst

E removeFirst()
Removes and answers the first element of this sequence.

Returns:
the removed element
Throws:
NoSuchElementException - if this sequence is empty

removeLast

E removeLast()
Removes and answers the last element of this sequence.

Returns:
the removed element
Throws:
NoSuchElementException - if this sequence is empty


© Copyright 2004-2008 Paul R. Holser, Jr. All rights reserved. Licensed under the Academic Free License version 3.0. pholser@alumni.rice.edu