00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 package cast.core;
00027
00028 import java.util.*;
00029
00033 public class SinglePlaceQueue<T> implements Queue<T> {
00034
00035 private T m_data = null;
00036
00037
00038
00039
00040
00041
00042 public T element() {
00043 if (m_data == null) {
00044 throw new NoSuchElementException("list empty");
00045 }
00046 return m_data;
00047 }
00048
00049
00050
00051
00052
00053
00054 public boolean offer(T _o) {
00055 m_data = _o;
00056 return true;
00057 }
00058
00059
00060
00061
00062
00063
00064 public T peek() {
00065 return m_data;
00066 }
00067
00068
00069
00070
00071
00072
00073 public T poll() {
00074 T ret = m_data;
00075 m_data = null;
00076 return ret;
00077 }
00078
00079
00080
00081
00082
00083
00084 public T remove() {
00085
00086 if (m_data == null) {
00087 throw new NoSuchElementException("list empty");
00088 }
00089
00090 T ret = m_data;
00091 m_data = null;
00092 return ret;
00093 }
00094
00095
00096
00097
00098
00099
00100 public boolean add(T _o) {
00101 m_data = _o;
00102 return true;
00103 }
00104
00105
00106
00107
00108
00109
00110 public boolean addAll(Collection<? extends T> _c) {
00111 throw new UnsupportedOperationException("bad idea");
00112 }
00113
00114
00115
00116
00117
00118
00119 public void clear() {
00120 m_data = null;
00121 }
00122
00123
00124
00125
00126
00127
00128 public boolean contains(Object _o) {
00129 if (m_data == null) {
00130 return false;
00131 }
00132 else {
00133 return m_data.equals(_o);
00134 }
00135 }
00136
00137
00138
00139
00140
00141
00142 public boolean containsAll(Collection<?> _c) {
00143 return false;
00144 }
00145
00146
00147
00148
00149
00150
00151 public boolean isEmpty() {
00152 return m_data == null;
00153 }
00154
00155
00156
00157
00158
00159
00160 public Iterator<T> iterator() {
00161 return null;
00162 }
00163
00164
00165
00166
00167
00168
00169 public boolean remove(Object _o) {
00170 throw new UnsupportedOperationException("bad idea");
00171 }
00172
00173
00174
00175
00176
00177
00178 public boolean removeAll(Collection<?> _c) {
00179 throw new UnsupportedOperationException("bad idea");
00180 }
00181
00182
00183
00184
00185
00186
00187 public boolean retainAll(Collection<?> _c) {
00188 throw new UnsupportedOperationException("bad idea");
00189 }
00190
00191
00192
00193
00194
00195
00196 public int size() {
00197 if (m_data == null) {
00198 return 0;
00199 }
00200 else {
00201 return 1;
00202 }
00203 }
00204
00205
00206
00207
00208
00209
00210 public Object[] toArray() {
00211 throw new UnsupportedOperationException("bad idea");
00212 }
00213
00214
00215
00216
00217
00218
00219 @SuppressWarnings("hiding")
00220 public <T> T[] toArray(T[] _a) {
00221 throw new UnsupportedOperationException("bad idea");
00222 }
00223
00224 }