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. *
  35. * @since Commons Collections 2.1
  36. * @version $Revision: 1.10 $ $Date: 2004/02/18 01:15:42 $
  37. *
  38. * @author Avalon
  39. * @author Berin Loritsch
  40. * @author Paul Jack
  41. * @author Stephen Colebourne
  42. */
  43. public interface Buffer extends Collection {
  44. /**
  45. * Gets and removes the next object from the buffer.
  46. *
  47. * @return the next object in the buffer, which is also removed
  48. * @throws BufferUnderflowException if the buffer is already empty
  49. */
  50. Object remove();
  51. /**
  52. * Gets the next object from the buffer without removing it.
  53. *
  54. * @return the next object in the buffer, which is not removed
  55. * @throws BufferUnderflowException if the buffer is empty
  56. */
  57. Object get();
  58. }