KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > corba > se > impl > encoding > BufferQueue


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
9 import java.util.LinkedList JavaDoc;
10 import java.util.NoSuchElementException JavaDoc;
11 import java.util.LinkedList JavaDoc;
12
13 /**
14  * Simple unsynchronized queue implementation for ByteBufferWithInfos.
15  */

16 // XREVISIT - Should be in orbutil or package private
17
public class BufferQueue
18 {
19     private LinkedList JavaDoc list = new LinkedList JavaDoc();
20     
21     public void enqueue(ByteBufferWithInfo item)
22     {
23         list.addLast(item);
24     }
25     
26     public ByteBufferWithInfo dequeue() throws NoSuchElementException JavaDoc
27     {
28         return (ByteBufferWithInfo)list.removeFirst();
29     }
30     
31     public int size()
32     {
33         return list.size();
34     }
35
36     // Adds the given ByteBufferWithInfo to the front
37
// of the queue.
38
public void push(ByteBufferWithInfo item)
39     {
40         list.addFirst(item);
41     }
42 }
43
Popular Tags