MCPcopy Create free account
hub / github.com/OSGeo/gdal / FindSortedInsertionPoint

Method FindSortedInsertionPoint

port/cplstringlist.cpp:1076–1103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1074/************************************************************************/
1075
1076int CPLStringList::FindSortedInsertionPoint(const char *pszLine)
1077
1078{
1079 CPLAssert(IsSorted());
1080
1081 int iStart = 0;
1082 int iEnd = nCount - 1;
1083
1084 while (iStart <= iEnd)
1085 {
1086 const int iMiddle = (iEnd + iStart) / 2;
1087 const char *pszMiddle = papszList[iMiddle];
1088
1089 if (CPLCompareKeyValueString(pszLine, pszMiddle) < 0)
1090 iEnd = iMiddle - 1;
1091 else
1092 iStart = iMiddle + 1;
1093 }
1094
1095 iEnd++;
1096 CPLAssert(iEnd >= 0 && iEnd <= nCount);
1097 CPLAssert(iEnd == 0 ||
1098 CPLCompareKeyValueString(pszLine, papszList[iEnd - 1]) >= 0);
1099 CPLAssert(iEnd == nCount ||
1100 CPLCompareKeyValueString(pszLine, papszList[iEnd]) <= 0);
1101
1102 return iEnd;
1103}
1104
1105namespace cpl
1106{

Callers

nothing calls this directly

Calls 2

IsSortedFunction · 0.85
CPLCompareKeyValueStringFunction · 0.85

Tested by

no test coverage detected