001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.collections;
018
019 import java.util.Collection;
020
021 /**
022 * Defines a collection that allows objects to be removed in some well-defined order.
023 * <p>
024 * The removal order can be based on insertion order (eg, a FIFO queue or a
025 * LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator
026 * (eg, a priority queue) or on any other well-defined ordering.
027 * <p>
028 * Note that the removal order is not necessarily the same as the iteration
029 * order. A <code>Buffer</code> implementation may have equivalent removal
030 * and iteration orders, but this is not required.
031 * <p>
032 * This interface does not specify any behavior for
033 * {@link Object#equals(Object)} and {@link Object#hashCode} methods. It
034 * is therefore possible for a <code>Buffer</code> implementation to also
035 * also implement {@link java.util.List}, {@link java.util.Set} or
036 * {@link Bag}.
037 *
038 * @since Commons Collections 2.1
039 * @version $Revision: 646777 $ $Date: 2008-04-10 13:33:15 +0100 (Thu, 10 Apr 2008) $
040 *
041 * @author Avalon
042 * @author Berin Loritsch
043 * @author Paul Jack
044 * @author Stephen Colebourne
045 */
046 public interface Buffer extends Collection {
047
048 /**
049 * Gets and removes the next object from the buffer.
050 *
051 * @return the next object in the buffer, which is also removed
052 * @throws BufferUnderflowException if the buffer is already empty
053 */
054 Object remove();
055
056 /**
057 * Gets the next object from the buffer without removing it.
058 *
059 * @return the next object in the buffer, which is not removed
060 * @throws BufferUnderflowException if the buffer is empty
061 */
062 Object get();
063
064 }