|
| 1 | +/** |
| 2 | + * Copyright (c) Rich Hickey. All rights reserved. |
| 3 | + * The use and distribution terms for this software are covered by the |
| 4 | + * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) |
| 5 | + * which can be found in the file epl-v10.html at the root of this distribution. |
| 6 | + * By using this software in any fashion, you are agreeing to be bound by |
| 7 | + * the terms of this license. |
| 8 | + * You must not remove this notice, or any other, from this software. |
| 9 | + **/ |
| 10 | + |
| 11 | +/* rich Mar 3, 2008 */ |
| 12 | + |
| 13 | +package clojure.lang; |
| 14 | + |
| 15 | +public abstract class ATransientSet extends AFn implements ITransientSet{ |
| 16 | + ITransientMap impl; |
| 17 | + |
| 18 | + ATransientSet(ITransientMap impl) { |
| 19 | + this.impl = impl; |
| 20 | + } |
| 21 | + |
| 22 | + public int count() { |
| 23 | + return impl.count(); |
| 24 | + } |
| 25 | + |
| 26 | + public ITransientSet conj(Object val) { |
| 27 | + ITransientMap m = impl.assoc(val, val); |
| 28 | + if (m != impl) this.impl = m; |
| 29 | + return this; |
| 30 | + } |
| 31 | + |
| 32 | + public boolean contains(Object key) { |
| 33 | + return this != impl.valAt(key, this); |
| 34 | + } |
| 35 | + |
| 36 | + public ITransientSet disjoin(Object key) throws Exception { |
| 37 | + ITransientMap m = impl.without(key); |
| 38 | + if (m != impl) this.impl = m; |
| 39 | + return this; |
| 40 | + } |
| 41 | + |
| 42 | + public Object get(Object key) { |
| 43 | + return impl.valAt(key); |
| 44 | + } |
| 45 | + |
| 46 | + public Object invoke(Object key, Object notFound) throws Exception { |
| 47 | + return impl.valAt(key, notFound); |
| 48 | + } |
| 49 | + |
| 50 | + public Object invoke(Object key) throws Exception { |
| 51 | + return impl.valAt(key); |
| 52 | + } |
| 53 | + |
| 54 | +} |
0 commit comments