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

Class APersistentSet

src/jvm/clojure/lang/APersistentSet.java:20–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18import java.util.Set;
19
20public abstract class APersistentSet extends AFn implements IPersistentSet, Collection, Set, Serializable, IHashEq {
21
22private static final long serialVersionUID = 889908853183699706L;
23
24int _hash;
25int _hasheq;
26final IPersistentMap impl;
27
28protected APersistentSet(IPersistentMap impl){
29 this.impl = impl;
30}
31
32public String toString(){
33 return RT.printString(this);
34}
35
36public boolean contains(Object key){
37 return impl.containsKey(key);
38}
39
40public Object get(Object key){
41 return impl.valAt(key);
42}
43
44public int count(){
45 return impl.count();
46}
47
48public ISeq seq(){
49 return RT.keys(impl);
50}
51
52public Object invoke(Object arg1) {
53 return get(arg1);
54}
55
56public boolean equals(Object obj){
57 return setEquals(this, obj);
58}
59
60static public boolean setEquals(IPersistentSet s1, Object obj) {
61 if(s1 == obj) return true;
62 if(!(obj instanceof Set))
63 return false;
64 Set m = (Set) obj;
65
66 if(m.size() != s1.count())
67 return false;
68
69 for(Object aM : m)
70 {
71 if(!s1.contains(aM))
72 return false;
73 }
74
75 return true;
76}
77

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected