Set.insert

Inserts the value from a forward range into the set.

  1. size_t insert(T value)
  2. size_t insert(T value)
  3. size_t insert(R range)
    struct Set(T, alias hasher = hash)
    size_t
    insert
    (
    R
    )
    (
    scope R range
    )
    if (
    isHashFunction!(hasher, T)
    )

Parameters

R

Range type.

range R

Forward range.

Return Value

Type: size_t

The number of new elements inserted.

Examples

Set!int set;

int[3] range = [2, 1, 2];

assert(set.insert(range[]) == 2);
assert(1 in set);
assert(2 in set);

Meta