View Javadoc

1   /*
2    *  Copyright 2002-2004 The Apache Software Foundation
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package net.sf.collections15;
17  
18  import java.util.Collection;
19  
20  /***
21   * Defines a collection that allows objects to be removed in some well-defined
22   * order.
23   * <p>
24   * The removal order can be based on insertion order (eg, a FIFO queue or a
25   * LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator
26   * (eg, a priority queue) or on any other well-defined ordering.
27   * <p>
28   * Note that the removal order is not necessarily the same as the iteration
29   * order.  A <code>Buffer</code> implementation may have equivalent removal
30   * and iteration orders, but this is not required.
31   * <p>
32   * This interface does not specify any behavior for 
33   * {@link Object#equals(Object)} and {@link Object#hashCode} methods.  It
34   * is therefore possible for a <code>Buffer</code> implementation to also
35   * also implement {@link java.util.List}, {@link java.util.Set} or 
36   * {@link Bag}.
37   *
38   * @since Commons Collections 2.1
39   * @version $Revision: 1.1 $ $Date: 2005/03/19 07:13:35 $
40   * 
41   * @author Avalon
42   * @author Berin Loritsch
43   * @author Paul Jack
44   * @author Stephen Colebourne
45   * @author Mauro Franceschini (port to 5.0)
46   */
47  public interface Buffer<E> extends Collection<E> {
48  
49      /***
50       * Gets and removes the next object from the buffer.
51       *
52       * @return the next object in the buffer, which is also removed
53       * @throws BufferUnderflowException if the buffer is already empty
54       */
55      E remove();
56  
57      /***
58       * Gets the next object from the buffer without removing it.
59       *
60       * @return the next object in the buffer, which is not removed
61       * @throws BufferUnderflowException if the buffer is empty
62       */
63      E get();
64  
65  }