KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > queue > ListAddRemoveFirstLastImpl


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Vivien Quema
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.queue;
26
27 import java.util.LinkedList JavaDoc;
28
29 import org.objectweb.dream.AbstractComponent;
30 import org.objectweb.dream.util.EmptyStringArray;
31
32 /**
33  * The ListAddRemoveFirstLastFastImpl class implements the
34  * {@link org.objectweb.dream.queue.List},
35  * {@link org.objectweb.dream.queue.ListAddFirstLast}, and
36  * {@link org.objectweb.dream.queue.ListRemoveFirstLast}interfaces using a
37  * {@link java.util.LinkedList}.
38  * <p>
39  * <i>Note: </i>None of the methods in this linked list are synchronized.
40  * <p>
41  */

42 public class ListAddRemoveFirstLastImpl extends AbstractComponent
43     implements
44       List,
45       ListAddFirstLast,
46       ListRemoveFirstLast
47 {
48
49   private LinkedList JavaDoc list = new LinkedList JavaDoc();
50
51   //---------------------------------------------------------------------------
52
// Implementation of the List interface.
53
// ---------------------------------------------------------------------------
54

55   /**
56    * @see List#add(Object)
57    */

58   public void add(Object JavaDoc o)
59   {
60     list.add(o);
61   }
62
63   /**
64    * @see List#remove()
65    */

66   public Object JavaDoc remove()
67   {
68     return list.removeFirst();
69   }
70
71   /**
72    * @see List#isEmpty()
73    */

74   public boolean isEmpty()
75   {
76     return list.isEmpty();
77   }
78
79   //---------------------------------------------------------------------------
80
// Implementation of the ListAddFirstLast interface.
81
// ---------------------------------------------------------------------------
82

83   /**
84    * @see ListAddFirstLast#addLast(Object)
85    */

86   public void addLast(Object JavaDoc o)
87   {
88     list.addLast(o);
89   }
90
91   /**
92    * @see ListAddFirstLast#addFirst(Object)
93    */

94   public void addFirst(Object JavaDoc o)
95   {
96     list.addFirst(o);
97   }
98
99   //---------------------------------------------------------------------------
100
// Implementation of the ListRemoveFirstLast interface.
101
// ---------------------------------------------------------------------------
102

103   /**
104    * @see ListRemoveFirstLast#getLast()
105    */

106   public Object JavaDoc getLast()
107   {
108     return list.getLast();
109   }
110
111   /**
112    * @see ListRemoveFirstLast#removeLast()
113    */

114   public Object JavaDoc removeLast()
115   {
116     return list.removeLast();
117   }
118
119   /**
120    * @see ListRemoveFirstLast#getFirst()
121    */

122   public Object JavaDoc getFirst()
123   {
124     return list.getFirst();
125   }
126
127   /**
128    * @see ListRemoveFirstLast#removeFirst()
129    */

130   public Object JavaDoc removeFirst()
131   {
132     return list.removeFirst();
133   }
134
135   // ---------------------------------------------------------------------------
136
// Implementation of the BindingController interface.
137
// ---------------------------------------------------------------------------
138

139   /**
140    * @see org.objectweb.fractal.api.control.BindingController#listFc()
141    */

142   public String JavaDoc[] listFc()
143   {
144     return EmptyStringArray.EMPTY_STRING_ARRAY;
145   }
146
147 }
Popular Tags