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 org.apache.commons.collections;
  17. import java.util.Collection;
  18. /**
  19. * Defines a collection that allows objects to be removed in some well-defined order.
  20. * <p>
  21. * The removal order can be based on insertion order (eg, a FIFO queue or a
  22. * LIFO stack), on access order (eg, an LRU cache), on some arbitrary comparator
  23. * (eg, a priority queue) or on any other well-defined ordering.
  24. * <p>
  25. * Note that the removal order is not necessarily the same as the iteration
  26. * order. A <code>Buffer</code> implementation may have equivalent removal
  27. * and iteration orders, but this is not required.
  28. * <p>
  29. * This interface does not specify any behavior for
  30. * {@link Object#equals(Object)} and {@link Object#hashCode} methods. It
  31. * is therefore possible for a <code>Buffer</code> implementation to also
  32. * also implement {@link java.util.List}, {@link java.util.Set} or
  33. * {@link Bag}.
  34. * <p>
  35. * <strong>Note:</strong> this class should be bytecode-identical to the
  36. * version in commons collections. This is required to allow backwards
  37. * compability with both previous versions of BeanUtils and also allow
  38. * coexistance with both collections 2.1 and 3.0.
  39. *
  40. * @since Commons Collections 2.1
  41. * @version $Revision: 1.1 $ $Date: 2004/05/10 19:50:28 $
  42. *
  43. * @author Avalon
  44. * @author Berin Loritsch
  45. * @author Paul Jack
  46. * @author Stephen Colebourne
  47. */
  48. public interface Buffer extends Collection {
  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. Object remove();
  56. /**
  57. * Gets the next object from the buffer without removing it.
  58. *
  59. * @return the next object in the buffer, which is not removed
  60. * @throws BufferUnderflowException if the buffer is empty
  61. */
  62. Object get();
  63. }