Is there a function for this?

Ali Çehreli acehreli at yahoo.com
Sat Oct 6 20:57:21 UTC 2018


On 10/06/2018 01:07 PM, bauss wrote:

 > uniq will not work with, say a class and the class will require you to
 > implement opCmp, which you can't always do for classes you don't have
 > access to.

Remembering that uniq works with a custom predicate, which should be 
sufficient in most of those case.

 > to use ..sort
 > and it requires opCmp again.

Same for sort: works with a custom predicate.

 > Things like .group and .uniq should work without sorted
 > ranges. You can't always expect a range to be sorted to perform such
 > algorithms.

Yes, it can be inconvenient but I'm under the impression that making 
algorithmic complexity a property of a function is agreed by most 
people. (For D, algorithmic complexity is in the documentations of 
functions; alas, uniq lacks it.) So, it's a good thing that we know that 
uniq is always O(N).

Ali



More information about the Digitalmars-d-learn mailing list