On Wednesday, 12 September 2012 at 17:24:57 UTC, monarch_dodra wrote:
[SNIP]
I did some tests and implementations, and I came with 3 options: 1) Embrace the "view of a chain" implementation and document it. 2) Use classic reference semantics. However, ranges can still have an "out of bonds" view of the chain. This means the ranges are virtually never invalidated. 3) Use classic reference semantics. ENFORCE range bounds be inside the underlying DList. This forces us to systematically "detach" removed nodes (as opposed to just advancing the _first pointer) ... 4) There was a 4th solution I did not like: use classic reference semantics. Do not provide support for "out of bounds" view of the Range, but do not enforce it either. This is the "Bites you in the ass" solution, and kind of what we currently had :( All 3 solutions have been implemented. Common to all 3 implementations: *Added a LOT of unit tests. *Added a description in the beggining *Fixed the opOpAssign functions. I know they weren't working because their names were typoed (!). *MUCH more robust assertions of internals (and minor bugfixes). *Ranges are now assertion based validated. (as opposed to enforced). Implementation 1: This embraces the "chain" view. It works as advertised. The downside though is in the concept, in that it _IS_ actually possible to invalidate a DList itself (not just the range). Everything is Asserted, and I do not think it is possible to have some bad usage which isn't asserted. I had to change a few implementations, but everything works now. Here: https://github.com/monarchdodra/phobos/commit/054fe9bea5652aa0e3089d279d4df2ae069d9f30#std/container.d Implementation 2: Reference semantics. However, Ranges can still have an out of bounds view of the chain. This is because functions like "removeFront" don't actually detach nodes, merelly advance the get pointer. The *real* advantage of this approach is that Range are virtually never invalidated. Also had to change a few implementations. This is kind of a hybrid soltuion, as the DLists themselves keep the traditional semantics, but the ranges themselves are more of a "can see anywhere in the chain" object. https://github.com/monarchdodra/phobos/commit/2b08b46bf552f208deb897ec0f8c5b3327225c8c#std/container.d Implementation 3: Classic implementation. No surprises. Robust, safe, expected. Boring. Boring is good. IMO, this is what people expect. Not a lot of changes here actually. https://github.com/monarchdodra/phobos/commit/8ce21e1a9a0107e74ff86a9acc736595ef73362c#std/container.d Could I get any kind of feedback?
