MCPcopy Create free account
hub / github.com/bytedance/bolt / linearSearchSimple

Function linearSearchSimple

bolt/type/tests/StringViewTest.cpp:197–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197int32_t linearSearchSimple(
198 StringView key,
199 const StringView* strings,
200 const int32_t* indices,
201 int32_t numStrings) {
202 if (indices) {
203 for (auto i = 0; i < numStrings; ++i) {
204 if (strings[indices[i]] == key) {
205 return i;
206 }
207 }
208 } else {
209 for (auto i = 0; i < numStrings; ++i) {
210 if (strings[i] == key) {
211 return i;
212 }
213 }
214 }
215 return -1;
216}
217
218TEST(StringView, linearSearch) {
219 constexpr int32_t kSize = 1003;

Callers 1

TESTFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected