digitalmars.D.learn - Sorted Array Wrapper Range
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (9/9) Dec 03 2014 Have anybody written a generic automatically sorted range wrapper
- Xinok (5/14) Dec 03 2014 There was a relevant discussion about a month ago here:
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/5) Dec 03 2014 I can't any reference to code, typically for SortedRange. Has
- Tobias Pankrath (2/11) Dec 03 2014 You won't be able to grow that range, would you?
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/10) Dec 06 2014 Why, because of slice invalidation?
- Tobias Pankrath (4/15) Dec 06 2014 Because a RandomAccessRange has no means to grow in general.
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (4/7) Dec 06 2014 So what should the basic operations in a SortedRange wrapper
- Tobias Pankrath (11/18) Dec 07 2014 Something like this
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/14) Dec 08 2014 Thanks! I don't get any linker errors using dmd git master. I'll
- Tobias Pankrath (5/25) Dec 08 2014 Was my fault. The phobos checkout didn't match my dmd version.
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/7) Dec 08 2014 Great! You should do a PR when you're satisfied! :)
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (2/3) Dec 10 2014 https://github.com/D-Programming-Language/phobos/pull/2793
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (4/8) Dec 08 2014 You have an outdated reference to BinaryHeap at line 440
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (5/9) Dec 10 2014 Further it's nicer to use new enum syntax at
Have anybody written a generic automatically sorted range wrapper for RandomAccessRanges? I guess http://dlang.org/library/std/range/assumeSorted.html should play a key role. I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearch
Dec 03 2014
On Wednesday, 3 December 2014 at 21:02:05 UTC, Nordlöw wrote:Have anybody written a generic automatically sorted range wrapper for RandomAccessRanges? I guess http://dlang.org/library/std/range/assumeSorted.html should play a key role. I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearchThere was a relevant discussion about a month ago here: http://forum.dlang.org/thread/uhfpppdslxdghyconlfr forum.dlang.org Otherwise, there's RedBlackTree, but I'm not aware of anything that works over any random-access range.
Dec 03 2014
On Thursday, 4 December 2014 at 04:24:26 UTC, Xinok wrote:There was a relevant discussion about a month ago here: http://forum.dlang.org/thread/uhfpppdslxdghyconlfr forum.dlang.orgI can't any reference to code, typically for SortedRange. Has this been implemented somewhere?
Dec 03 2014
On Wednesday, 3 December 2014 at 21:02:05 UTC, Nordlöw wrote:Have anybody written a generic automatically sorted range wrapper for RandomAccessRanges? I guess http://dlang.org/library/std/range/assumeSorted.html should play a key role. I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearchYou won't be able to grow that range, would you?
Dec 03 2014
On Thursday, 4 December 2014 at 07:58:25 UTC, Tobias Pankrath wrote:Why, because of slice invalidation?I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearchYou won't be able to grow that range, would you?
Dec 06 2014
On Saturday, 6 December 2014 at 14:10:21 UTC, Nordlöw wrote:On Thursday, 4 December 2014 at 07:58:25 UTC, Tobias Pankrath wrote:Because a RandomAccessRange has no means to grow in general. Compare your proposed wrapper toWhy, because of slice invalidation?I see two typical variants: - Direct: Always sorts on write() and modify() - Lazy: Sorts lazily on read() read() of course uses binarySearchYou won't be able to grow that range, would you?
Dec 06 2014
On Saturday, 6 December 2014 at 14:14:18 UTC, Tobias Pankrath wrote:Because a RandomAccessRange has no means to grow in general. Compare your proposed wrapper toSo what should the basic operations in a SortedRange wrapper template be? And how should the wrapped type be restricted?
Dec 06 2014
On Saturday, 6 December 2014 at 14:50:02 UTC, Nordlöw wrote:On Saturday, 6 December 2014 at 14:14:18 UTC, Tobias Pankrath wrote:Something like this https://github.com/Panke/phobos/blob/std_container_sorted/std/container/sorted.d It should additionally support c.remove(r), c.removeKey(k), opIn and insertFront/removeFront if the underlying store supports them. But that's pretty much it, I'd say. Sadly, the unittest using an Array!int as store does not compile because of of linker errors. I'm using rdmd -unittest -main std/container/sorted.d but that does not work with std/container/array.d as well. So, my setup seems to be broken.Because a RandomAccessRange has no means to grow in general. Compare your proposed wrapper toSo what should the basic operations in a SortedRange wrapper template be? And how should the wrapped type be restricted?
Dec 07 2014
On Sunday, 7 December 2014 at 13:12:06 UTC, Tobias Pankrath wrote:Something like this https://github.com/Panke/phobos/blob/std_container_sorted/std/container/sorted.d It should additionally support c.remove(r), c.removeKey(k), opIn and insertFront/removeFront if the underlying store supports them. But that's pretty much it, I'd say. Sadly, the unittest using an Array!int as store does not compile because of of linker errors. I'm using rdmd -unittest -main std/container/sorted.d but that does not work with std/container/array.d as well. So, my setup seems to be broken.Thanks! I don't get any linker errors using dmd git master. I'll try 2.066 later on. I'll do some polishing :)
Dec 08 2014
On Monday, 8 December 2014 at 13:34:33 UTC, Nordlöw wrote:On Sunday, 7 December 2014 at 13:12:06 UTC, Tobias Pankrath wrote:Was my fault. The phobos checkout didn't match my dmd version. Here is my current state (has some more unittest, bugs fixed, no assignment via SortedRange views on Sorted.): https://github.com/Panke/phobos/blob/sorted/std/container/sorted.dSomething like this https://github.com/Panke/phobos/blob/std_container_sorted/std/container/sorted.d It should additionally support c.remove(r), c.removeKey(k), opIn and insertFront/removeFront if the underlying store supports them. But that's pretty much it, I'd say. Sadly, the unittest using an Array!int as store does not compile because of of linker errors. I'm using rdmd -unittest -main std/container/sorted.d but that does not work with std/container/array.d as well. So, my setup seems to be broken.Thanks! I don't get any linker errors using dmd git master. I'll try 2.066 later on. I'll do some polishing :)
Dec 08 2014
On Monday, 8 December 2014 at 15:43:37 UTC, Tobias Pankrath wrote:Was my fault. The phobos checkout didn't match my dmd version. Here is my current state (has some more unittest, bugs fixed, no assignment via SortedRange views on Sorted.): https://github.com/Panke/phobos/blob/sorted/std/container/sorted.dGreat! You should do a PR when you're satisfied! :) Is there anything you need help with?
Dec 08 2014
On Monday, 8 December 2014 at 20:18:51 UTC, Nordlöw wrote:Great! You should do a PR when you're satisfied! :)https://github.com/D-Programming-Language/phobos/pull/2793
Dec 10 2014
On Monday, 8 December 2014 at 15:43:37 UTC, Tobias Pankrath wrote:Was my fault. The phobos checkout didn't match my dmd version. Here is my current state (has some more unittest, bugs fixed, no assignment via SortedRange views on Sorted.): https://github.com/Panke/phobos/blob/sorted/std/container/sorted.dYou have an outdated reference to BinaryHeap at line 440 https://github.com/Panke/phobos/blob/sorted/std/container/sorted.d#L440 Should be replaced with Sorted I presume.
Dec 08 2014
On Monday, 8 December 2014 at 15:43:37 UTC, Tobias Pankrath wrote:Was my fault. The phobos checkout didn't match my dmd version. Here is my current state (has some more unittest, bugs fixed, no assignment via SortedRange views on Sorted.): https://github.com/Panke/phobos/blob/sorted/std/container/sorted.dFurther it's nicer to use new enum syntax at https://github.com/Panke/phobos/blob/sorted/std/container/sorted.d#L12 as enum isRAContainer(T) = isRandomAccessRange!(typeof(T.init[])) ...
Dec 10 2014