On 30-Jun-12 18:25, Andrei Alexandrescu wrote:
On 6/30/12 9:15 AM, Dmitry Olshansky wrote:
On 30-Jun-12 15:35, Tobias Pankrath wrote:
Say I have a forward range (for example, an SList[]). I would like to
create a new range containing only the first 5 elements of that old
range. How can I do that?
std.algorithm.take.
But I would generally avoid SList.
Indeed. I'd be hard pressed to devise realistic use case where it
performs better.
Singly-linked lists are frequently used with lock-free algorithms.
As post involved terms like "generally" I pointed out that indeed List
should not be used "generally" :) Their value in certain scenarios is
remarkable, or rather of linked storage such as in free lists, and (like
you mentioned) certain lock-free algorithms.
Let's not forget however that what people seek is lock-free queues and
other high-level abstractions. S-lists just happen to be a means to an
end that works on current hardware.
I totally expect a new wave of simpler lock-free algorithms with things
like Intel's TSX and something analogous that AMD will have.
(others would either copy or redesign similar things as it's an obvious
need for the future multicores)
There a lot of links but this gives a nice overview and is fairly new:
http://arstechnica.com/business/2012/02/transactional-memory-going-mainstream-with-intel-haswell/
Generally it's simplistic to compare slists with arrays as to "which
performs better" because they have different primitives.
Agreed. Though it's not at all uncommon to mix things up in awful ways.
*cough* Java *cough*
--
Dmitry Olshansky