distinct

Performs a linear scan of buf from [0 .. buf.length$(RP), moving all but the first element of each consecutive group of duplicate elements to the end of the sequence. The relative order of all remaining elements will be preserved. Comparisons will be performed using the supplied predicate or '==' if none is supplied.

  1. size_t distinct(Elem[] buf, Pred2E pred)
    version(TangoDoc)
    distinct
  2. template distinct(Buf)
  3. template distinct(Buf, Pred)

Parameters

buf Elem[]

The array to scan. This parameter is not marked 'ref' to allow temporary slices to be modified. As buf is not resized in any way, omitting the 'ref' qualifier has no effect on the result of this operation, even though it may be viewed as a side-effect.

pred Pred2E

The evaluation predicate, which should return true if e1 is equal to e2 and false if not. This predicate may be any callable type.

Return Value

Type: size_t

The number of distinct sub-sequences in buf.

Meta