MCPcopy Create free account
hub / github.com/catboost/catboost / VerE

Method VerE

library/cpp/expression/expression_variable.cpp:230–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228 return 0.0;
229}
230double TExpressionVariable::VerE(const TExpressionVariable& secondOperand) const {
231 /* Сравнение версий по стандарту uatraits:
232 1) Версию мы всегда считаем из первых четырех чисел, остальные игнорируем.
233 Если меньше четырех, добавляем недостающие нули.
234 2) Если в каком-то из операндов мусор, какие-то префиксы или постфиксы, то
235 операторы <#, <=#, >#, >=# и ==# вернут false, !=# вернёт true.
236 См. примеры в тестах */
237
238 const auto ss_first = StringSplitter(StripString(StringValue)).Split('.').Take(4);
239 const auto ss_second = StringSplitter(StripString(secondOperand.StringValue)).Split('.').Take(4);
240 auto first = ss_first.begin(), second = ss_second.begin();
241 ui32 firstValue, secondValue;
242
243 while (first != ss_first.end() && second != ss_second.end()) {
244 if (!TryFromString<ui32>(*first, firstValue) || !TryFromString<ui32>(*second, secondValue) || firstValue != secondValue) {
245 return 0.0;
246 }
247 ++first;
248 ++second;
249 }
250
251 while (first != ss_first.end()) {
252 if (!TryFromString<ui32>(*first, firstValue) || firstValue != 0){
253 return 0.0;
254 }
255 ++first;
256 }
257
258 while (second != ss_second.end()) {
259 if (!TryFromString<ui32>(*second, secondValue) || secondValue != 0){
260 return 0.0;
261 }
262 ++second;
263 }
264
265 return 1.0;
266}
267double TExpressionVariable::VerNe(const TExpressionVariable& secondOperand) const {
268 return VerE(secondOperand) == 1.0 ? 0.0 : 1.0;
269}

Callers 2

CalcVariantExpressionMethod · 0.80
Y_UNIT_TESTFunction · 0.80

Calls 6

StringSplitterFunction · 0.85
StripStringFunction · 0.85
TakeMethod · 0.45
SplitMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected