MCPcopy Create free account
hub / github.com/NVIDIA/cuda-quantum / countOccurrences

Function countOccurrences

targettests/execution/dem_from_kernel.cpp:180–188  ·  view source on GitHub ↗

Count occurrences of @p needle in @p haystack. Used to tally how many `error(` lines the returned `.dem` text contains.

Source from the content-addressed store, hash-verified

178// Count occurrences of @p needle in @p haystack. Used to tally how many
179// `error(` lines the returned `.dem` text contains.
180static std::size_t countOccurrences(const std::string &haystack,
181 const std::string &needle) {
182 std::size_t count = 0, pos = 0;
183 while ((pos = haystack.find(needle, pos)) != std::string::npos) {
184 ++count;
185 pos += needle.size();
186 }
187 return count;
188}
189
190// Detectors and observables appear in the `.dem` file as TARGETS in
191// `error(...)` lines, not as standalone instructions. `D5` is a reference

Callers 3

runCaseFunction · 0.70
runTrivialFunction · 0.70
runNoNoiseCaseFunction · 0.70

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected