rlm@10: /** rlm@10: * Copyright (c) Rich Hickey. All rights reserved. rlm@10: * The use and distribution terms for this software are covered by the rlm@10: * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) rlm@10: * which can be found in the file epl-v10.html at the root of this distribution. rlm@10: * By using this software in any fashion, you are agreeing to be bound by rlm@10: * the terms of this license. rlm@10: * You must not remove this notice, or any other, from this software. rlm@10: **/ rlm@10: rlm@10: /* rich Mar 3, 2008 */ rlm@10: rlm@10: package clojure.lang; rlm@10: rlm@10: public abstract class ATransientSet extends AFn implements ITransientSet{ rlm@10: ITransientMap impl; rlm@10: rlm@10: ATransientSet(ITransientMap impl) { rlm@10: this.impl = impl; rlm@10: } rlm@10: rlm@10: public int count() { rlm@10: return impl.count(); rlm@10: } rlm@10: rlm@10: public ITransientSet conj(Object val) { rlm@10: ITransientMap m = impl.assoc(val, val); rlm@10: if (m != impl) this.impl = m; rlm@10: return this; rlm@10: } rlm@10: rlm@10: public boolean contains(Object key) { rlm@10: return this != impl.valAt(key, this); rlm@10: } rlm@10: rlm@10: public ITransientSet disjoin(Object key) throws Exception { rlm@10: ITransientMap m = impl.without(key); rlm@10: if (m != impl) this.impl = m; rlm@10: return this; rlm@10: } rlm@10: rlm@10: public Object get(Object key) { rlm@10: return impl.valAt(key); rlm@10: } rlm@10: rlm@10: public Object invoke(Object key, Object notFound) throws Exception { rlm@10: return impl.valAt(key, notFound); rlm@10: } rlm@10: rlm@10: public Object invoke(Object key) throws Exception { rlm@10: return impl.valAt(key); rlm@10: } rlm@10: rlm@10: }