array to clean from duplicate values
foreach/opApply() style delegate, called with the index and the value of each array element that is equal to the previous element, returns 0 to continue or a value different from 0 to stop iteration.
- 0 if no duplicates were found so found() was not called or - 0 if found() returned 0 on each call or - the non-zero value returned by found() on the last call.
Sorts array and iterates over each array element that compares equal to the previous element.
To just check for the existence of duplicates it's recommended to make found() return true (or some other value different from 0) to stop the iteration after the first duplicate.
To assert array has no duplicates or throw an exception if it has, put the assert(false) or throw ... in found():
Template params: T = type of array element sort = true: do array.sort first; false: array is already sorted