# std::philox_engine<UIntType,w,n,r,consts>::set_counter

> C++ Atlas: `cppatlas.com/w/cpp/numeric/random/philox_engine/set_counter` | Source: https://en.cppreference.com/w/cpp/numeric/random/philox_engine/set_counter | Domain: Numerics | Standards: C++26

Sets the counter of the random-number engine.

## Official Specification Summary (cppreference)

```cpp
void set_counter( const std::array<result_type, n>& c ); // (since C++26)
```

Sets the counter of the random-number engine.

- For each integer `k` in `[​0​,` `n)`, sets X^(k) to c^(n-1-k) mod 2^(w).
- The value of `j` is set to `n - 1`.[1]

1. ↑ As `j` is being set to `n - 1`, the next state transition always generates new random values.

### Parameters

- `c` - counter sequence to use to set the counter

### Complexity

O(n).

### See also

- [(constructor)](https://en.cppreference.com/w/cpp/numeric/random/philox_engine/philox_engine): constructs the engine (public member function)
- [`seed`](https://en.cppreference.com/w/cpp/numeric/random/philox_engine/seed): sets the current state of the engine (public member function)

---
Attribution: content from https://en.cppreference.com/w/cpp/numeric/random/philox_engine/set_counter (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.