Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.kaosko</groupId>
<artifactId>data.avl</artifactId>
<version>0.0.19-SNAPSHOT</version>
<version>0.0.20-SNAPSHOT</version>
<name>data.avl</name>
<description>Persistent sorted maps and sets with log-time rank queries</description>

Expand Down Expand Up @@ -35,7 +36,7 @@
</scm>

<properties>
<clojure.version>1.5.1</clojure.version>
<clojure.version>1.9.0</clojure.version>
<clojure.warnOnReflection>true</clojure.warnOnReflection>
</properties>

Expand Down
20 changes: 10 additions & 10 deletions src/main/cljs/clojure/data/avl.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@
(cond
(zero? c)
[(.getLeft node)
[(.getKey node) (.getVal node)]
(MapEntry. (.getKey node) (.getVal node) nil)
(.getRight node)]

(neg? c)
Expand Down Expand Up @@ -697,7 +697,7 @@
(avl-map-reduce (.getLeft node) f init))]
(if (reduced? init)
init
(let [init (f init [(.getKey node) (.getVal node)])]
(let [init (f init (MapEntry. (.getKey node) (.getVal node) nil))]
(if (reduced? init)
init
(if (nil? (.getRight node))
Expand All @@ -714,7 +714,7 @@
(if (nil? (.getRight node))
init
(avl-map-reduce (.getRight node) f init))
(let [init (f init [(.getKey node) (.getVal node)])]
(let [init (f init (MapEntry. (.getKey node) (.getVal node) nil))]
(if (reduced? init)
init
(if (nil? (.getRight node))
Expand Down Expand Up @@ -768,7 +768,7 @@
ISeq
(-first [this]
(let [node (peek stack)]
[(.-key node) (.-val node)]))
(MapEntry. (.-key node) (.-val node) nil)))

(-rest [this]
(let [node (first stack)
Expand Down Expand Up @@ -828,7 +828,7 @@

(nearest [this test k]
(if-let [node (lookup-nearest comp tree test k)]
[(.getKey node) (.getVal node)]))
(MapEntry. (.getKey node) (.getVal node) nil)))

IHash
(-hash [this]
Expand All @@ -849,12 +849,12 @@
IIndexed
(-nth [this i]
(if-let [n (select tree i)]
[(.getKey n) (.getVal n)]
(MapEntry. (.getKey n) (.getVal n) nil)
(throw (ex-info "nth index out of bounds in AVL tree" {}))))

(-nth [this i not-found]
(if-let [n (select tree i)]
[(.getKey n) (.getVal n)]
(MapEntry. (.getKey n) (.getVal n) nil)
not-found))

ICollection
Expand Down Expand Up @@ -884,9 +884,9 @@
(-reduce [this f]
(case cnt
0 (f)
1 [(.getKey tree) (.getVal tree)]
1 (MapEntry. (.getKey tree) (.getVal tree) nil)
(let [n0 (select tree 0)
init (avl-map-reduce-skip tree f [(.getKey n0) (.getVal n0)] n0)]
init (avl-map-reduce-skip tree f (MapEntry. (.getKey n0) (.getVal n0) nil) n0)]
(if (reduced? init)
(-deref init)
init))))
Expand Down Expand Up @@ -1210,7 +1210,7 @@
AVLSet
(-pr-writer [this writer opts]
(pr-sequential-writer writer pr-writer "#{" " " "}" opts this)))

(defn sorted-map
"keyval => key val
Returns a new AVL map with supplied mappings."
Expand Down