/
AASet.clj
87 lines (72 loc) · 2.15 KB
/
AASet.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
(ns aatree.AASet
(:gen-class
:main false
:extends clojure.lang.APersistentSet
:implements [clojure.lang.IObj
clojure.lang.Reversible
clojure.lang.Sorted
clojure.lang.Counted
clojure.lang.Indexed
aatree.nodes.INoded]
:constructors {[aatree.AAMap]
[clojure.lang.IPersistentMap]
[aatree.AAMap clojure.lang.IPersistentMap]
[clojure.lang.IPersistentMap]}
:init init
:state impl)
(:require [aatree.nodes :refer :all])
(:import (aatree AAMap AASet)
(clojure.lang MapEntry RT IPersistentMap ISeq)
(aatree.nodes INode)))
(set! *warn-on-reflection* true)
(defn -getState [^AASet this]
(let [^AAMap mpl (.-impl this)]
(.-state mpl)))
(defn -init
([aamap]
[[aamap] aamap])
([aamap meta]
(let [mpl (with-meta aamap meta)]
[[mpl] mpl])))
(defn -meta [this] (get-meta this))
(defn -withMeta [^AASet this meta] (new AASet (.-impl this) meta))
(defn -disjoin [^AASet this key]
(if (contains? this key)
(new AASet (dissoc (.-impl this) key))
this))
(defn -cons [^AASet this key]
(if (contains? this key)
this
(new AASet (assoc (.-impl this) key key))))
(defn -empty [^AASet this]
(new AASet (empty (.-impl this))))
(defn -rseq [^AASet this]
(let [^AAMap mpl (.-impl this)
^ISeq rs (.rseq mpl)]
(clojure.lang.APersistentMap$KeySeq/create rs)))
(defn -comparator [^AASet this]
(let [^AAMap mpl (.-impl this)]
(.comparator mpl)))
(defn -entryKey [entry]
entry)
(defn -seq
([^AASet this]
(-seq this true))
([^AASet this ascending]
(let [^AAMap mpl (.-impl this)]
(RT/keys (.seq mpl ascending)))))
(defn -seqFrom [^AASet this key ascending]
(let [^AAMap mpl (.-impl this)]
(RT/keys (.seqFrom mpl key ascending))))
(defn -count [^AASet this]
(let [^AAMap mpl (.-impl this)]
(.count mpl)))
(defn -nth
([^AASet this var1]
(let [^AAMap mpl (.-impl this)
^MapEntry e (.nth mpl var1)]
(.getKey e)))
([^AASet this var1 var2]
(let [^AAMap mpl (.-impl this)
^MapEntry e (.nth mpl var1 var2)]
(.getKey e))))