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

Class Tr

util/string/util.h:159–189  ·  view source on GitHub ↗

an analogue of tr/$from/$to/

Source from the content-addressed store, hash-verified

157
158// an analogue of tr/$from/$to/
159class Tr {
160public:
161 Tr(const char* from, const char* to);
162
163 char ConvertChar(char ch) const {
164 return Map[(ui8)ch];
165 }
166
167 void Do(char* s) const {
168 for (; *s; s++) {
169 *s = ConvertChar(*s);
170 }
171 }
172 void Do(const char* src, char* dst) const {
173 for (; *src; src++) {
174 *dst++ = ConvertChar(*src);
175 }
176 *dst = 0;
177 }
178 void Do(char* s, size_t l) const {
179 for (size_t i = 0; i < l && s[i]; i++) {
180 s[i] = ConvertChar(s[i]);
181 }
182 }
183 void Do(TString& str) const;
184
185private:
186 char Map[256];
187
188 size_t FindFirstChangePosition(const TString& str) const;
189};
190
191// Removes all occurrences of given character from string
192template <typename TStringType>

Callers 2

TrMethod · 0.85
operator[]Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected