<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in data.int-map</title>
<link>https://ask.clojure.org/index.php/questions/contrib-libs/data-int-map</link>
<description></description>
<item>
<title>Document that clojure.data.int-map is sorted</title>
<link>https://ask.clojure.org/index.php/12778/document-that-clojure-data-int-map-is-sorted</link>
<description>&lt;p&gt;Recently a question about it &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1679007293266749&quot;&gt;was asked on Slack&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/DIMAP-4&quot;&gt;DIMAP-4 Jira ticket&lt;/a&gt; has made the map and the set deliberately sorted, but it was never mentioned in the docs.&lt;br&gt;
Seems like it could be explicitly mentioned in the docstrings?&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12778/document-that-clojure-data-int-map-is-sorted</guid>
<pubDate>Fri, 17 Mar 2023 08:58:14 +0000</pubDate>
</item>
<item>
<title>Should data.int-map's allow assoc'ing non-integer keys?</title>
<link>https://ask.clojure.org/index.php/12588/should-data-int-maps-allow-associng-non-integer-keys</link>
<description>&lt;p&gt;Here's a question, in Clojure there are our typical HashMaps which allow assoc'ing any kind of keys on them, and then we have some more specialized kinds of maps for specific keys. Most of them are however also open to allow assoc'ing keys outside their usual range, gracefully reverting to hashmaps when the operation would break the data structure's invariants. Examples below:&lt;/p&gt;
&lt;p&gt;Records are open to assoc, and revert to hashmaps when dissoc'ing a record field&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defrecord Person [name lang])
;; =&amp;gt; clojure.data.int_map_test.Person
(let [p (-&amp;gt;Person &quot;john&quot; &quot;en_CA&quot;)]
  [p (assoc p :foo :bar) (dissoc p :lang)])
;; =&amp;gt;
;; [#clojure.data.int_map_test.Person{:name &quot;john&quot;, :lang &quot;en_CA&quot;}
;; #clojure.data.int_map_test.Person{:name &quot;john&quot;, :lang &quot;en_CA&quot;, :foo :bar}
;; {:name &quot;john&quot;}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On the other hand, struct-maps are open to assoc, but closed to dissoc&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [sm (struct-map (create-struct :name :lang) :name &quot;John&quot; :lang &quot;en_CA&quot;)]
  [(assoc sm :foo &quot;bar&quot;)
   (try (dissoc sm :lang) (catch Exception e (.toString e)))])
    =&amp;gt; [{:name &quot;John&quot;, :lang &quot;en_CA&quot;, :foo &quot;bar&quot;} 
        &quot;java.lang.RuntimeException: Can't remove struct key&quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An other example is ArrayMaps which eventually turn into HashMaps as they grow. That's not exactly the same, there's no specific key outside the map's range, but similar in a more general sense of, when an operation either violates invariants or performance expectations, fall back to the general HashMap. &lt;/p&gt;
&lt;p&gt;That makes me wonder, how do people feel about int-map/int-set which instead throw exception if you try and add a non-integer key? &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(assoc (i/int-map 1 2) :a &quot;b&quot;)
ClassCastException class clojure.lang.Keyword cannot be cast to class java.lang.Number
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Should it be modified to fall back to a hashmap instead? It seems like that is more in line with Clojure philosophy of open data structures. &lt;/p&gt;
&lt;p&gt;It could be implemented similar to &lt;code&gt;PersistentStructMap&lt;/code&gt;, which holds an extra map in which it stores extra key/value pairs which are not part of the struct's definition:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;final IPersistentMap ext;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same thing could be done in PersistentIntMap&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(deftype PersistentIntMap
  [^INode root
   ^long epoch
   meta
   ^IPersistentMap ext]
  ;; ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;What do you think?&lt;/p&gt;
&lt;p&gt;Also, the same question but for int-sets&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12588/should-data-int-maps-allow-associng-non-integer-keys</guid>
<pubDate>Fri, 27 Jan 2023 03:03:54 +0000</pubDate>
</item>
<item>
<title>clojure.data.int-map Branch nodes allocate unused ArrayLists</title>
<link>https://ask.clojure.org/index.php/12555/clojure-data-int-map-branch-nodes-allocate-unused-arraylists</link>
<description>&lt;p&gt;I see here &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/data.int-map/blob/master/src/main/java/clojure/data/int_map/Nodes.java#L376&quot;&gt;https://github.com/clojure/data.int-map/blob/master/src/main/java/clojure/data/int_map/Nodes.java#L376&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;There is an unused &lt;code&gt;List&amp;lt;INode&amp;gt; above = new ArrayList&amp;lt;INode&amp;gt;();&lt;/code&gt; being created, it should probably be removed.&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12555/clojure-data-int-map-branch-nodes-allocate-unused-arraylists</guid>
<pubDate>Mon, 16 Jan 2023 07:33:46 +0000</pubDate>
</item>
<item>
<title>clojure.data.int-map Branch nodes could use bitmaps to save space</title>
<link>https://ask.clojure.org/index.php/12554/clojure-data-int-map-branch-nodes-could-use-bitmaps-save-space</link>
<description>&lt;p&gt;In clojure.data.int-map contrib library, the &lt;code&gt;INode&lt;/code&gt; impelementation &lt;code&gt;Branch&lt;/code&gt; stores its children always in an &lt;code&gt;INode[]&lt;/code&gt; of length 16, even though often/usually, not all 16 of the children's spots are taken up. For instance, the representation of &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(int-map 0 0 1 0) 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will be represented with a Branch node with an &lt;code&gt;INode[]&lt;/code&gt; where the 0-position contains 0-&amp;gt;0, the 1-position contains 1-&amp;gt;0, and the other 14 spaces in the array are &lt;code&gt;null&lt;/code&gt;, see below:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/2CikRja.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;This is a difference to the core hashmap/hashset implementation which uses a (in their case, 32-bit, but the branching factor in int-map is only 16) bitmap to keep track of which positions in the array are present and then at read time you can see how many bits are present (set to 1) in the bitmap, to the right of the index you want to read, and that tells you what the true index in the compressed array is.   &lt;/p&gt;
&lt;p&gt;It would probably be worth taking a look at if use of bitmaps could positively effect performance and memory use of int-map's here.  &lt;/p&gt;
&lt;p&gt;Could also try compressing further by combining the bitmap and/or mask and/or prefix and/or offset because these fields are large enough that they are not using all of their bits.  mask (long), for instance, is only ever one of 15, 15 &amp;lt;&amp;lt; 4, 15 &amp;lt;&amp;lt; 8, 15 &amp;lt;&amp;lt; 12, etc. offset (int) is only ever 0 ... 60 I think. And prefix (long) similarly is only storing a binary representation of a bitmask between 0...64 in length so in principle could be compressed quite a bit too. Among these I bet there would be a field to store some 16 bits of a bitmask without having to add an other field. &lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12554/clojure-data-int-map-branch-nodes-could-use-bitmaps-save-space</guid>
<pubDate>Mon, 16 Jan 2023 06:31:31 +0000</pubDate>
</item>
<item>
<title>clojure.data.int-map could use shared empty singleton instances</title>
<link>https://ask.clojure.org/index.php/12553/clojure-data-int-map-could-shared-empty-singleton-instances</link>
<description>&lt;h3&gt;Shared empty int-map&lt;/h3&gt;
&lt;p&gt;I notice that in the contrib library &lt;code&gt;clojure.data.int-map&lt;/code&gt;, a new instance of the empty &lt;code&gt;PersistentIntMap&lt;/code&gt; is created every time &lt;code&gt;(int-map)&lt;/code&gt; is called. This is different to how all the other persistent collections work, where there's only one single empty list/vector/map/set exists, and it is reused.&lt;/p&gt;
&lt;p&gt;It's also the same situation with &lt;code&gt;PersistentIntSet&lt;/code&gt;, both dense and non-dense.&lt;/p&gt;
&lt;h3&gt;(empty my-int-map) doesn't preserve meta&lt;/h3&gt;
&lt;p&gt;the &lt;code&gt;IPersistentCollection#empty()&lt;/code&gt; implementation on &lt;code&gt;PersistentIntMap&lt;/code&gt; is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  (empty [this]
      (PersistentIntMap. Nodes$Empty/EMPTY 0 nil))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So the metadata from &lt;code&gt;this&lt;/code&gt; is lost in the returned empty int-map. Other strict collection implementations retain metadata in the returned collection:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(mapv (fn [coll] (meta (empty (with-meta coll {:a 1})))) 
    [() [] {} #{} (sorted-map) (sorted-set)])
=&amp;gt; [{:a 1} {:a 1} {:a 1} {:a 1} {:a 1} {:a 1}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same is true for &lt;code&gt;PersistentIntSet&lt;/code&gt;&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12553/clojure-data-int-map-could-shared-empty-singleton-instances</guid>
<pubDate>Mon, 16 Jan 2023 05:05:11 +0000</pubDate>
</item>
<item>
<title>`intersection` and `union` do not support `nil` punning</title>
<link>https://ask.clojure.org/index.php/10996/intersection-and-union-do-not-support-nil-punning</link>
<description>&lt;p&gt;This is for org.clojure/data.int-map  v 1.0.0.&lt;br&gt;
At the same time &lt;code&gt;clojure.set/intersection&lt;/code&gt; and &lt;code&gt;clojure.set/union&lt;/code&gt; handle the case well.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns sandbox
  (:require
   [clojure.data.int-map :as int-map]
   [clojure.set]))

(clojure.set/intersection #{1 3} #{1 2 3}) ; =&amp;gt; #{1 3}
(clojure.set/intersection #{1 3} nil) ; =&amp;gt; nil
(clojure.set/intersection nil #{1 2 3}) ; =&amp;gt; nil

(int-map/intersection (int-map/int-set #{1 3}) (int-map/int-set #{1 2 3})) ; =&amp;gt; #{1 3}
(int-map/intersection (int-map/int-set #{1 3}) nil) ; =&amp;gt; NullPointerException
(int-map/intersection nil (int-map/int-set #{1 2 3})) ; =&amp;gt; NullPointerException

(clojure.set/union #{1 3} #{2}) ; =&amp;gt; #{1 3 2}
(clojure.set/union #{1 3} nil) ; =&amp;gt; #{1 3}
(clojure.set/union nil #{2}) ; =&amp;gt; #{2}

(int-map/union (int-map/int-set #{1 3}) (int-map/int-set #{2})) ; =&amp;gt; #{1 2 3}
(int-map/union (int-map/int-set #{1 3}) nil) ; =&amp;gt; NullPointerException
(int-map/union nil (int-map/int-set #{2})) ; =&amp;gt; NullPointerException
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10996/intersection-and-union-do-not-support-nil-punning</guid>
<pubDate>Tue, 31 Aug 2021 16:51:39 +0000</pubDate>
</item>
<item>
<title>Why does PersistentPriorityMap kv-reduce call the reducing function with item and priority?</title>
<link>https://ask.clojure.org/index.php/10136/persistentprioritymap-reduce-reducing-function-priority</link>
<description>&lt;p&gt;Why does &lt;code&gt;reduce-kv&lt;/code&gt; on a priority-map call the reducing function with item as the key and priority as the value (&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/data.priority-map/blob/2adf0d7efb2be75b936bf2ff1e3e400d74ab64aa/src/main/clojure/clojure/data/priority_map.clj#L395-L397&quot;&gt;source&lt;/a&gt;) instead of the map's key and value. Calling &lt;code&gt;reduce&lt;/code&gt; will be passed the map's key and value. I'm assuming it has something to do with this particular data structure's origins, but I cannot find any documentation pointing me to in in the clojure.data.priority-map ns. Here is an example. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def m
  (clojure.data.priority-map/priority-map-keyfn-by first compare
    :a [2 :apples] :b [1 :bananas]))

(reduce-kv
  (fn [acc k v]
    (assoc acc k v))
  {} m)
=&amp;gt; {:b 1, :a 2}

(reduce
  (fn [acc [k v]]
    (assoc acc k v))
  {} m)
=&amp;gt; {:b [1 :bananas], :a [2 :apples]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this the expected behavior? If so, could we add some documentation that this is how reduce-kv on a PersistentPriorityMap should work? &lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10136/persistentprioritymap-reduce-reducing-function-priority</guid>
<pubDate>Mon, 01 Feb 2021 16:45:15 +0000</pubDate>
</item>
<item>
<title>int sets return false for .equals and = when comparing against java.util.Set, and similarly for int maps against java.ut</title>
<link>https://ask.clojure.org/index.php/8150/return-false-equals-comparing-against-java-similarly-against</link>
<description>&lt;p&gt;Most implementations of Clojure immutable maps and sets can return true when being compared against java.util.Map and java.util.Set instances (even mutable ones) if they currently have the same contents.&lt;/p&gt;
&lt;p&gt;The proposed patch to enable this for int sets and int maps has a test case that demonstrates this is not true for the latest library code.&lt;/p&gt;
&lt;p&gt;I would expect to get true for all of the .equals and = calls in the sample REPL session below.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user=&amp;gt; (def jset1 (java.util.HashSet. [1]))&lt;/p&gt;
&lt;h2&gt;'user/jset1&lt;/h2&gt;
&lt;p&gt;user=&amp;gt; (def intset1 (imap/int-set [1]))&lt;/p&gt;
&lt;h2&gt;'user/intset1&lt;/h2&gt;
&lt;p&gt;user=&amp;gt; (def cset1 #{1})&lt;/p&gt;
&lt;h2&gt;'user/cset1&lt;/h2&gt;
&lt;p&gt;user=&amp;gt; (.equals cset1 jset1)&lt;br&gt;
true&lt;br&gt;
user=&amp;gt; (= cset1 jset1)&lt;br&gt;
true&lt;br&gt;
user=&amp;gt; (.equals jset1 cset1)&lt;br&gt;
true&lt;br&gt;
user=&amp;gt; (= jset1 cset1)&lt;br&gt;
true&lt;br&gt;
user=&amp;gt; (.equals intset1 jset1)&lt;br&gt;
false&lt;br&gt;
user=&amp;gt; (= intset1 jset1)&lt;br&gt;
false&lt;br&gt;
user=&amp;gt; (.equals jset1 intset1)&lt;br&gt;
true&lt;br&gt;
user=&amp;gt; (= jset1 intset1)&lt;br&gt;
false&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8150/return-false-equals-comparing-against-java-similarly-against</guid>
<pubDate>Wed, 09 May 2018 03:51:15 +0000</pubDate>
</item>
<item>
<title>PersistentIntMap equals/equiv gives wrong result</title>
<link>https://ask.clojure.org/index.php/8142/persistentintmap-equals-equiv-gives-wrong-result</link>
<description>&lt;p&gt;{{PersistentIntMap}} {{equals}} and {{equiv}} are currently broken for maps that have the same keys, but with different values:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
clojure.data.int-map&amp;gt; (= (int-map 1 :foo)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                     (int-map 1 :bar))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;; =&amp;gt; true&lt;br&gt;
clojure.data.int-map&amp;gt; (.equals (int-map 1 :foo)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                           (int-map 1 :bar))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;; =&amp;gt; true&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The bug was introduced in (link: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/data.int-map/commit/fccd5e4bd1dc42b8ea50c80081e785ea68f36dd6&quot;&gt;https://github.com/clojure/data.int-map/commit/fccd5e4bd1dc42b8ea50c80081e785ea68f36dd6&lt;/a&gt; text: this commit) addressing (link: &lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.clojure.org/jira/browse/DIMAP-11&quot;&gt;https://dev.clojure.org/jira/browse/DIMAP-11&lt;/a&gt; text: DIMAP-11).&lt;/p&gt;
&lt;p&gt;Cause/fix is simple, see attached patch.&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8142/persistentintmap-equals-equiv-gives-wrong-result</guid>
<pubDate>Wed, 27 Sep 2017 11:12:42 +0000</pubDate>
</item>
<item>
<title>support element lookup on transient sets</title>
<link>https://ask.clojure.org/index.php/8151/support-element-lookup-on-transient-sets</link>
<description>&lt;p&gt;This is related to &lt;a rel=&quot;nofollow&quot; href=&quot;https://dev.clojure.org/jira/browse/CLJ-700&quot;&gt;https://dev.clojure.org/jira/browse/CLJ-700&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;contains? doesnt work on transient collections&lt;/p&gt;
&lt;p&gt;Now of course the expectation of how data.int-map should work is the same as with a general set so I dont complain there. However, a workaround shown in this thread: &lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/forum/#!topic/clojure/lQVmZ-jcdiU&quot;&gt;https://groups.google.com/forum/#!topic/clojure/lQVmZ-jcdiU&lt;/a&gt; is to use the set directly as a function:&lt;/p&gt;
&lt;p&gt;;; this works&lt;br&gt;
((transient #{1 2 3}) 2)&lt;br&gt;
;=&amp;gt; 2&lt;/p&gt;
&lt;p&gt;;; this doesnt :(&lt;br&gt;
((transient (int-set #{1 2 3})) 2)&lt;br&gt;
;=&amp;gt; CompilerException java.lang.IllegalArgumentException: contains? not supported on type: clojure.data.int_map.TransientIntSet&lt;/p&gt;
&lt;p&gt;I checked the code and the TransientIntSet supports the contain method of the TransientIntSet interface which could be used directly and return the correct value but it is definitely not idiomatic to recur to interop nor have to look that around for this specific case.&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8151/support-element-lookup-on-transient-sets</guid>
<pubDate>Mon, 26 Jun 2017 07:41:18 +0000</pubDate>
</item>
<item>
<title>Cannot merge int-sets of different density.</title>
<link>https://ask.clojure.org/index.php/8144/cannot-merge-int-sets-of-different-density</link>
<description>&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(iset/union (iset/int-set)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        (iset/dense-int-set))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;throws java.lang.IllegalArgumentException: Cannot merge int-sets of different density.&lt;/p&gt;
&lt;p&gt;Now this might not be a bug per se, but the README on GitHub claims that &lt;/p&gt;
&lt;p&gt;bq. dense-int-set behaves the same as int-set, the difference is only in their memory efficiency.&lt;/p&gt;
&lt;p&gt;I think it should either be possible to mix dense/normal sets, or state explicitly in the documentation that it isn't and also possibly update the error message since it wasn't obvious to me that this is the cause (I had totally forgotten I had used dense sets in this one place and believed the problem to be caused by transients).&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8144/cannot-merge-int-sets-of-different-density</guid>
<pubDate>Wed, 21 Sep 2016 12:09:08 +0000</pubDate>
</item>
<item>
<title>Unlike regular transient sets, data.int-map transient sets do not support the IFn interface</title>
<link>https://ask.clojure.org/index.php/8146/unlike-regular-transient-sets-transient-support-interface</link>
<description>&lt;p&gt;=&amp;gt; ((transient (clojure.data.int-map/dense-int-set 1)) 1)&lt;br&gt;
IllegalArgumentException Don't know how to create ISeq from: java.lang.Long  clojure.lang.RT.seqFrom (RT.java:545)&lt;/p&gt;
&lt;p&gt;=&amp;gt; ((transient #{1}) 1)&lt;br&gt;
1&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8146/unlike-regular-transient-sets-transient-support-interface</guid>
<pubDate>Fri, 01 Jul 2016 09:22:04 +0000</pubDate>
</item>
<item>
<title>Union, intersection and difference have only 2 arguments versions</title>
<link>https://ask.clojure.org/index.php/8147/union-intersection-difference-have-only-arguments-versions</link>
<description>&lt;p&gt;The arities of the special union, intersection and difference operations don't match the arities of those in clojure.set.&lt;/p&gt;
&lt;p&gt;|operation   |clojure.set|int-set|&lt;br&gt;
| :-- | :-- | :-- | :-- |&lt;br&gt;
|union        | 0, 1, 2, n | 2 |&lt;br&gt;
|intersection |    1, 2, n | 2 |&lt;br&gt;
|difference   |    1, 2, n | 2 |&lt;/p&gt;
&lt;p&gt;This prevents using int-sets as a drop-in replacement for sets.&lt;/p&gt;
&lt;p&gt;Looking at the source of clojure.set, those seem to be implemented via simple reduce for difference, and bubbled-sets (via bubble-max-key) for union and intersection.&lt;/p&gt;
&lt;p&gt;Could a similar approach be used here? I'm willing to work on this.&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8147/union-intersection-difference-have-only-arguments-versions</guid>
<pubDate>Sun, 01 Nov 2015 01:28:14 +0000</pubDate>
</item>
<item>
<title>Minor typos in README and docstring</title>
<link>https://ask.clojure.org/index.php/8145/minor-typos-in-readme-and-docstring</link>
<description>&lt;p&gt;Fixes two very minor typos.&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8145/minor-typos-in-readme-and-docstring</guid>
<pubDate>Wed, 30 Sep 2015 13:27:08 +0000</pubDate>
</item>
<item>
<title>int-map doc string is overly restrictive?</title>
<link>https://ask.clojure.org/index.php/8143/int-map-doc-string-is-overly-restrictive</link>
<description>&lt;p&gt;Doc string for int-map is &quot;Creates an integer map that can only have non-negative integers as keys.&quot;, but it seems that the implementation may work fine for any integer in the range of a Java Long, positive or negative?&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8143/int-map-doc-string-is-overly-restrictive</guid>
<pubDate>Tue, 29 Sep 2015 23:44:23 +0000</pubDate>
</item>
<item>
<title>Proper seq on int-sets</title>
<link>https://ask.clojure.org/index.php/8149/proper-seq-on-int-sets</link>
<description>&lt;p&gt;Empty intersection of int-sets return () from clojure.lang.Seqable.seq().&lt;/p&gt;
&lt;p&gt;&lt;code&gt;user&amp;gt; (dorun (map #(println &quot;set contains:&quot; %) (intersection (int-set [1]) (int-set [2]))))
set contains: nil
nil&lt;/code&gt;&lt;/p&gt;
</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8149/proper-seq-on-int-sets</guid>
<pubDate>Tue, 28 Oct 2014 15:48:48 +0000</pubDate>
</item>
<item>
<title>Support efficient rseq on int maps</title>
<link>https://ask.clojure.org/index.php/8148/support-efficient-rseq-on-int-maps</link>
<description>As discussed previously in &lt;a href=&quot;https://github.com/ztellman/immutable-int-map/pull/1&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://github.com/ztellman/immutable-int-map/pull/1&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I note that the existing Seq implementation is not lazy, so i've just implemented a basic reverse iterator around this rather than walking the tree right-first - I was actually fairly surprised core clojure doesn't provide Reversible for ArrayLists already.&lt;br /&gt;
&lt;br /&gt;
Patch taken from &lt;a href=&quot;https://github.com/glenjamin/data.int-map/tree/rseq&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://github.com/glenjamin/data.int-map/tree/rseq&lt;/a&gt; attached, benchmarks below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (require '[clojure.data.benchmark :refer (entries)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;#_=&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'[clojure.data.int-map :as i]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;#_=&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'[criterium.core :as c])&lt;br /&gt;
nil&lt;br /&gt;
user=&amp;gt;&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (let [m (into (i/int-map) entries)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;#_=&amp;gt; &amp;nbsp;&amp;nbsp;(println &amp;quot;seq&amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;#_=&amp;gt; &amp;nbsp;&amp;nbsp;(c/quick-bench (dorun (seq m)))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;#_=&amp;gt; &amp;nbsp;&amp;nbsp;(println &amp;quot;rseq&amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;#_=&amp;gt; &amp;nbsp;&amp;nbsp;(c/quick-bench (dorun (rseq m))))&lt;br /&gt;
seq&lt;br /&gt;
WARNING: Final GC required 8.9263203426305 % of runtime&lt;br /&gt;
WARNING: Final GC required 48.03202811726098 % of runtime&lt;br /&gt;
Evaluation count : 12 in 6 samples of 2 calls.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time mean : 75.794581 ms&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time std-deviation : 421.571821 µs&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time lower quantile : 75.476998 ms ( 2.5%)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time upper quantile : 76.483561 ms (97.5%)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Overhead used : 2.127421 ns&lt;br /&gt;
&lt;br /&gt;
Found 1 outliers in 6 samples (16.6667 %)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; low-severe&amp;nbsp; &amp;nbsp; &amp;nbsp;1 (16.6667 %)&lt;br /&gt;
&amp;nbsp;Variance from outliers : 13.8889 % Variance is moderately inflated by outliers&lt;br /&gt;
rseq&lt;br /&gt;
WARNING: Final GC required 54.64906330819225 % of runtime&lt;br /&gt;
Evaluation count : 6 in 6 samples of 1 calls.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time mean : 101.840831 ms&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time std-deviation : 723.601456 µs&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time lower quantile : 100.881998 ms ( 2.5%)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Execution time upper quantile : 102.496873 ms (97.5%)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Overhead used : 2.127421 ns&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
CLA has been signed.</description>
<category>data.int-map</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8148/support-efficient-rseq-on-int-maps</guid>
<pubDate>Sat, 20 Sep 2014 16:16:55 +0000</pubDate>
</item>
</channel>
</rss>