moveToEnd

Performs a linear scan of complete array, moving all items matching element to the end of the sequence. The relative order of items not matching the matching element will be preserved. Comparisons will be performed using the supplied predicate or '==' if none is supplied.

  1. size_t moveToEnd(T[] array, T element, Pred pred)
    size_t
    moveToEnd
    (
    T[] array
    ,
    in T element
    ,
    Pred pred = Pred.init
    )
  2. size_t moveToEnd(Buffer!(T) array, T element, Pred pred)

Parameters

array T[]

The array to scan. This parameter is not marked 'ref' to allow temporary slices to be modified. As array 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.

element T

The element value to look for

pred Pred

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 elements that do not match element.

Examples

auto buffer = createBuffer("abbcc");
test!("==")(moveToEnd(buffer, 'b'), 3);
test!("==")(buffer[], "accbb");

Meta