-
Notifications
You must be signed in to change notification settings - Fork 4
Clojure Sorted Set
Bill La Forge edited this page Oct 15, 2015
·
7 revisions
When configured with aatree.core.standard-opts, the Sorted Set created by the aatree.core.new-sorted-set function is a standard, empty Clojure sorted-set.
(ns aatree.lazy-sorted-set-examples
(:require [aatree.core :refer :all])
(:import (java.nio ByteBuffer)))
(set! *warn-on-reflection* true)
(def opts (lazy-opts))
(def empty-set (new-sorted-set opts))
(println (lazy-byte-length empty-set)); -> 1
(def ls1 (conj empty-set :dog :cat :rabbit))
(println ls1); -> #{:cat :dog :rabbit}
(def ls1-len (lazy-byte-length ls1))
(println ls1-len); -> 85
(def ^ByteBuffer bb (ByteBuffer/allocate ls1-len))
(lazy-write ls1 bb)
(.flip bb)
(def ls2 (load-aaset bb))
(println ls2); -> #{:cat :dog :rabbit}