MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / FindInterval

Function FindInterval

SampleFramework12/v1.00/Graphics/Spectrum.cpp:41–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39
40template <typename Predicate>
41int FindInterval(int size, const Predicate &pred) {
42 int first = 0, len = size;
43 while (len > 0) {
44 int half = len >> 1, middle = first + half;
45 // Bisect range based on value of _pred_ at _middle_
46 if (pred(middle)) {
47 first = middle + 1;
48 len -= half + 1;
49 } else
50 len = half;
51 }
52 return Clamp(first - 1, 0, size - 2);
53}
54
55// Spectrum Method Definitions
56bool SpectrumSamplesSorted(const float *lambda, const float *vals, int n) {

Callers 1

Calls 1

ClampFunction · 0.85

Tested by

no test coverage detected