| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| ContractibleSequence |
|
| 0.0;0 |
| 1 | /* | |
| 2 | Copyright 2004-2008 Paul R. Holser, Jr. All rights reserved. | |
| 3 | Licensed under the Academic Free License version 3.0 | |
| 4 | */ | |
| 5 | ||
| 6 | package jaggregate; | |
| 7 | ||
| 8 | /** | |
| 9 | * Provides protocol for removing <dfn>elements</dfn> from an ordered collection of | |
| 10 | * objects, whose elements can be accessed using external <dfn>keys</dfn>. | |
| 11 | * | |
| 12 | * @param <E> a restriction on the types of elements that may be included in the | |
| 13 | * sequence | |
| 14 | * | |
| 15 | * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a> | |
| 16 | * @version $Id: ContractibleSequence.java,v 1.4 2008/05/07 06:00:49 pholser Exp $ | |
| 17 | */ | |
| 18 | public interface ContractibleSequence<E> extends Collection<E> { | |
| 19 | /** | |
| 20 | * {@inheritDoc} | |
| 21 | * | |
| 22 | * @return a contractible sequence of the transformations | |
| 23 | */ | |
| 24 | <R> ContractibleSequence<R> collect( | |
| 25 | UnaryFunctor<? super E, ? extends R> transformer ); | |
| 26 | ||
| 27 | /** | |
| 28 | * {@inheritDoc} | |
| 29 | * | |
| 30 | * @return a contractible sequence of the rejected elements of this sequence | |
| 31 | */ | |
| 32 | ContractibleSequence<E> reject( UnaryCondition<? super E> discriminator ); | |
| 33 | ||
| 34 | /** | |
| 35 | * {@inheritDoc} | |
| 36 | * | |
| 37 | * @return a contractible sequence of the selected elements of this sequence | |
| 38 | */ | |
| 39 | ContractibleSequence<E> select( UnaryCondition<? super E> discriminator ); | |
| 40 | ||
| 41 | /** | |
| 42 | * Removes and answers the element at a given position in this sequence. | |
| 43 | * | |
| 44 | * @param index the index at which to remove the element | |
| 45 | * @return the removed element | |
| 46 | * @throws IndexOutOfBoundsException if {@code index < 0} or {@code index >=} this | |
| 47 | * collection's {@linkplain #size() size} | |
| 48 | */ | |
| 49 | E removeAt( int index ); | |
| 50 | ||
| 51 | /** | |
| 52 | * Removes and answers the first element of this sequence. | |
| 53 | * | |
| 54 | * @return the removed element | |
| 55 | * @throws java.util.NoSuchElementException if this sequence is | |
| 56 | * {@linkplain #isEmpty() empty} | |
| 57 | */ | |
| 58 | E removeFirst(); | |
| 59 | ||
| 60 | /** | |
| 61 | * Removes and answers the last element of this sequence. | |
| 62 | * | |
| 63 | * @return the removed element | |
| 64 | * @throws java.util.NoSuchElementException if this sequence is | |
| 65 | * {@linkplain #isEmpty() empty} | |
| 66 | */ | |
| 67 | E removeLast(); | |
| 68 | } |