D Ranges in C#

Paulo Pinto pjmlp at progtools.org
Sat Jun 1 11:41:58 PDT 2013


Am 01.06.2013 20:23, schrieb Mehrdad:
> On Saturday, 1 June 2013 at 16:30:05 UTC, David Piepgrass wrote:
>>>> David Piepgrass:
>>>>> In fact, most STL algorithms require exactly two iterators--a
>>>>> range--and none require only a single iterator<
>>>>
>>>> I think there are some C++ data structures that store many single
>>>> iterators. If you instead store ranges you double the data amount.
>>>
>>> Hashmaps would be the most common example. Usually implemented as a
>>> linked list of key-value pairs along with a vector of list iterators.
>>
>> In theory. But the .NET hashtables are implemented with an *array* of
>> key-value pairs and an array of *indexes*. The former forms a virtual
>> linked list that is more efficient than a traditional linked list, and
>> the latter is more efficient than a vector of iterators (especially on
>> x64, as the indexes can be 32-bit.)
>
>
>
> Iterators are usually (but not always) faster, as they don't have an
> extra level of indirection involved -- the iterators tell you directly
> where to look in memory, whereas indices are useless without containers
> (or iterators) backing them.
>
>
> You shouldn't be using 32-bit indices on x64, that defeats the whole
> point of x64.

As of .NET 4.5, 64bit array indexes are supported as well.

http://msdn.microsoft.com/en-us/library/hh285054.aspx





More information about the Digitalmars-d mailing list