1. /*
  2. * @(#)BufferQueue.java 1.7 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.impl.encoding;
  8. import java.util.LinkedList;
  9. import java.util.NoSuchElementException;
  10. import java.util.LinkedList;
  11. /**
  12. * Simple unsynchronized queue implementation for ByteBufferWithInfos.
  13. */
  14. // XREVISIT - Should be in orbutil or package private
  15. public class BufferQueue
  16. {
  17. private LinkedList list = new LinkedList();
  18. public void enqueue(ByteBufferWithInfo item)
  19. {
  20. list.addLast(item);
  21. }
  22. public ByteBufferWithInfo dequeue() throws NoSuchElementException
  23. {
  24. return (ByteBufferWithInfo)list.removeFirst();
  25. }
  26. public int size()
  27. {
  28. return list.size();
  29. }
  30. // Adds the given ByteBufferWithInfo to the front
  31. // of the queue.
  32. public void push(ByteBufferWithInfo item)
  33. {
  34. list.addFirst(item);
  35. }
  36. }