Yes, we're on the same page here. I'm very glad Michał has done great work 
in this Clojure data structure space.

Of course, I wouldn't mind if dozens of people agreed, but I'm more 
interested in the pros/cons before I try to mobilize support. So, to those 
reading this, I'd be interested to hear if:

(a) you agree with CLJ-1008 (or some friendly amendment to it)
(b) you disagree with CLJ-1008 for some principled or philosophical reason 
(not just because you think other things are more pressing or you wouldn't 
personally use a a RB-Tree API right away)
(c) you think more exploration is needed

Some observations and context:

* I find it curious that `tree` is public but `left` and `right` are not. 
Perhaps this was just historical accident?

* Exposing the API for PersistentTreeMaps opens up a lot of useful 
possibilities for derivative data structures. (This is what led me to this 
question.) See, for example, interval trees, in particular ones with 
non-overlapping intervals: http://en.wikipedia.org/wiki/Interval_tree, 
which could be naively implemented with a PersistentTreeMap if it had 
public API access.

On Thursday, February 19, 2015 at 3:37:46 PM UTC-5, Andy Fingerhut wrote:
>
> David:
>
> I see why you would want that.
>
> If you want this soon, I would recommend using data.avl as suggested by 
> Michał, 
> or copy the parts of the sorted-set/map implementation from Clojure and 
> implement it yourself.
>
> If you don't want it soon, you could try persuading a few dozen people to 
> vote on CLJ-1008, and hope the Clojure developers also want this change.  
> No guarantees there.
>
> Andy
>
> On Thu, Feb 19, 2015 at 12:18 PM, David James <david...@gmail.com 
> <javascript:>> wrote:
>
>> Andy, to take advantage of the Red-Black Tree, I'm looking for public API 
>> access to the branches. (I'm not looking for a work-around.)
>>
>> More discussion on this at SO: 
>> http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-given-value-for-clojure-sorted-maps
>>
>> Thanks to both Michał Marczyk and Andy for commenting on CLJ-1008 (
>> http://dev.clojure.org/jira/browse/CLJ-1008).
>>
>> On Thursday, February 19, 2015 at 1:02:53 PM UTC-5, Andy Fingerhut wrote:
>>>
>>> I haven't checked carefully, but from at least a quick look it appears 
>>> that implementing the NavigableMap and NavigableSet interfaces could be 
>>> done by using the existing subseq and rsubseq functions in clojure.core?
>>>
>>> It doesn't give you access to subtree nodes directly, but perhaps it is 
>>> sufficient for your purposes?
>>>
>>> Andy
>>>
>>> On Wed, Feb 18, 2015 at 6:04 PM, David James <david...@gmail.com> wrote:
>>>
>>>> Summary: I'd like to find a public API to work with the underlying tree 
>>>> of a sorted-map.
>>>>
>>>> For example:
>>>>
>>>> (def t (sorted-map 1 :a 2 :b 3 :c 4 :d 5 :e 6 :f)) 
>>>>
>>>> The underlying implementation of sorted-map uses a PersistentTreeMap, 
>>>> which can be accessed with `tree`:
>>>>
>>>> (.tree t) ;=> [2 :b]
>>>>
>>>> I have not found a way to access the left and right branches, since 
>>>> calling `left` fails:
>>>>
>>>> (.left (.tree t))
>>>>
>>>> IllegalArgumentException Can't call public method of non-public class: 
>>>> public clojure.lang.PersistentTreeMap$Node clojure.lang.
>>>> PersistentTreeMap$BlackBranch.left()  
>>>> clojure.lang.Reflector.invokeMatchingMethod 
>>>> (Reflector.java:88)
>>>>
>>>> Perhaps it would be reasonable to make such calls possible, at least 
>>>> from the Java API (without reflection)?
>>>>
>>>> CLJ-1008 (http://dev.clojure.org/jira/browse/CLJ-1008) offers one 
>>>> possible way to support a public API. It was created in 2012. Perhaps it 
>>>> could use another look. Thoughts? 
>>>>
>>>>  -- 
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clo...@googlegroups.com
>>>> Note that posts from new members are moderated - please be patient with 
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> clojure+u...@googlegroups.com
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/clojure?hl=en
>>>> --- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to clojure+u...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> <javascript:>
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com <javascript:>
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to