On Saturday, 30 June 2012 at 12:27:38 UTC, bearophile wrote:
Tobias Pankrath:

But I would generally avoid SList.

It's not good.

And in general linked lists are quite overrated.
...
Bye,
bearophile

I appreciate the input, which I (mostly) agree with (I still love list's splice ability, which can be very powerful), but this isn't really what the question is about.

It's about getting generic algorithms to work with any generic range. Right now, they appear (to me) to heavily favor RA, even when they should theoretically support simple bidirectionality...

Those that do support directionality do it using "cheat" using take. For example:

void main()
{
  SList!int slist;
  foreach(i; iota(5,0,-1))
    slist.insertFront(i);

  auto rnge = slist[];
  auto fs = findSplit!("a == b")(rnge, [3]);

  writeln(fs[0]); // [1, 2]
  slist.insertAfter(take(rnge, 1), 25); //insert 25 between [1, 2]
  writeln(fs[0]); // [1, 25] !?  Should arguably be [1, 25, 2]
}

This, arguably, is not normal behavior. SList modeling forward ranges, ranges to the list should not be bounded by a fixed size.

And again, had my input been a BDList (if it existed), findSplit would have returned 3 forwardRanges, which is also arguably wrong.

Reply via email to