how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Sunil S Nandihalli
Hi Everybody, I would like to create a sorted-data-structure which would enable me to efficiently 1. insert new elements into it maintaining the sorted-nature of the data structure. 2. query as to which element is immediately before and after a value that I present. one can assume that the value

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Sunil S Nandihalli
I seem to miss the c++ stl library where it would be trivial to do this! Sunil. On Thu, Sep 1, 2011 at 3:43 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Everybody, I would like to create a sorted-data-structure which would enable me to efficiently 1. insert new elements

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Sunil S Nandihalli
I really feel sorted-set should have something to achieve what I want .. but don't seem to find it.. On Thu, Sep 1, 2011 at 3:53 PM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: I seem to miss the c++ stl library where it would be trivial to do this! Sunil. On Thu, Sep 1, 2011 at

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread David Powell
On Thu, Sep 1, 2011 at 11:13 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Everybody, I would like to create a sorted-data-structure which would enable me to efficiently 1. insert new elements into it maintaining the sorted-nature of the data structure. 2. query as to which

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Sunil S Nandihalli
Thanks Dave, That did it. I did not know there was rsubseq .. :) Thanks Sunil. On Thu, Sep 1, 2011 at 4:04 PM, David Powell djpow...@djpowell.net wrote: On Thu, Sep 1, 2011 at 11:13 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi Everybody, I would like to create a

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Alan Malloy
Well, the two calls to subseq are unpleasant and possibly slow. I was thinking there's a way to write it as a single operation that returns three items, say (subseq s = (dec 50)) to get the items before and after 50, but of course that doesn't work unless you know 49 is in there, and in that case

Re: how to create a ordered data structure which would efficiently return the element before and after it

2011-09-01 Thread Ken Wesson
On Thu, Sep 1, 2011 at 2:08 PM, Alan Malloy a...@malloys.org wrote: Well, the two calls to subseq are unpleasant and possibly slow. I was thinking there's a way to write it as a single operation that returns three items, say (subseq s = (dec 50)) to get the items before and after 50, but of