Why Strings as Classes?
Denis Koroskin
2korden at gmail.com
Tue Aug 26 12:58:10 PDT 2008
On Tue, 26 Aug 2008 23:29:33 +0400, superdan <super at dan.org> wrote:
[snip]
>> The D spec certainly doesn't make any guarantees about
>> the time/memory complexity of opIndex; it's up to the implementing class
>> to do so.
>
> it don't indeed. it should. that's a problem with the spec.
>
I agree. You can't rely on function invokation, i.e. the following might
be slow as death:
auto n = collection.at(i);
auto len = collection.length();
but index operations and properties getters should be real-time and have
O(1) complexity by design.
auto n = collection[i];
auto len = collection.length;
More information about the Digitalmars-d
mailing list