MCPcopy Index your code
hub / github.com/clojure/clojure / Single

Class Single

src/jvm/clojure/lang/TransformerIterator.java:137–169  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137private static class Single implements Buffer {
138 private volatile Object val;
139
140 public Single(Object o) {
141 this.val = o;
142 }
143
144 public Buffer add(Object o) {
145 if (val == NONE) {
146 val = o;
147 return this;
148 } else {
149 return new Many(val, o);
150 }
151 }
152
153 public Object remove() {
154 if(val == NONE) {
155 throw new IllegalStateException("Removing object from empty buffer");
156 }
157 Object ret = val;
158 val = NONE;
159 return ret;
160 }
161
162 public boolean isEmpty() {
163 return val == NONE;
164 }
165
166 public String toString() {
167 return "Single: " + val;
168 }
169}
170
171private static class Many implements Buffer {
172 private final Queue vals = new LinkedList();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected