From 40c573d559bdfe167a904a46eae23349a6f229e2 Mon Sep 17 00:00:00 2001 From: frankiesardo Date: Thu, 6 Nov 2014 19:11:50 +0000 Subject: [PATCH] Linked set prints iteself as a vector So the order is not lost. Uniqueness can always be added later. --- project.clj | 2 +- src/linked/set.cljx | 8 ++++---- test/linked/set_test.cljx | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/project.clj b/project.clj index 2fb6071..514c661 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject frankiesardo/linked "1.0.5" +(defproject frankiesardo/linked "1.0.6" :description "Efficient ordered map and set" :url "http://github.com/frankiesardo/linked" :license {:name "Eclipse Public License" diff --git a/src/linked/set.cljx b/src/linked/set.cljx index eb11148..ea8c59a 100644 --- a/src/linked/set.cljx +++ b/src/linked/set.cljx @@ -76,7 +76,7 @@ Object (toString [this] - (str "#{" (string/join " " (map str this)) "}")) + (str "[" (string/join " " (map str this)) "]")) (hashCode [this] (reduce + (map hash (.seq this)))) (equals [this other] @@ -89,14 +89,14 @@ #+clj (defmethod print-method LinkedSet [o ^java.io.Writer w] (.write w "#linked/set ") - (print-method (seq o) w)) + (print-method (into [] (seq o)) w)) #+cljs (deftype LinkedSet [linked-map] Object (toString [this] - (str "#{" (string/join " " (map str this)) "}")) + (str "[" (string/join " " (map str this)) "]")) (equiv [this other] (-equiv this other)) @@ -160,7 +160,7 @@ IPrintWithWriter (-pr-writer [coll writer opts] - (-write writer (str "#linked/set " (if-let [s (seq coll)] s '()))))) + (-write writer (str "#linked/set " (into [] (seq coll)))))) #+cljs (reader/register-tag-parser! "linked/set" linked-set) diff --git a/test/linked/set_test.cljx b/test/linked/set_test.cljx index f2450d5..0258a34 100644 --- a/test/linked/set_test.cljx +++ b/test/linked/set_test.cljx @@ -82,11 +82,11 @@ (deftest object-features (let [s (linked-set 'a 1 :b 2)] - (is (= "#{a 1 :b 2}" (str s))))) + (is (= "[a 1 :b 2]" (str s))))) (deftest print-and-read-ordered (let [s (linked-set 1 2 9 8 7 5)] - (is (= "#linked/set (1 2 9 8 7 5)" + (is (= "#linked/set [1 2 9 8 7 5]" (pr-str s))) (let [o (read-string (pr-str s))] #+clj (is (= linked.set.LinkedSet (type o)))