aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/containers/comptrie
diff options
context:
space:
mode:
authorlapshov <lapshov@yandex-team.ru>2022-02-10 16:49:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:49:39 +0300
commit4f36f44b1e216dca1f44ada8d126e7b70f05da2f (patch)
treeedbdb67ebe4b9195bf7c53bbc0a963fc03ccc17e /library/cpp/containers/comptrie
parent8b71ce88bea710a9663bb143e4916f961c57212e (diff)
downloadydb-4f36f44b1e216dca1f44ada8d126e7b70f05da2f.tar.gz
Restoring authorship annotation for <lapshov@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/containers/comptrie')
-rw-r--r--library/cpp/containers/comptrie/comptrie_builder.inl36
1 files changed, 18 insertions, 18 deletions
diff --git a/library/cpp/containers/comptrie/comptrie_builder.inl b/library/cpp/containers/comptrie/comptrie_builder.inl
index f273fa6571..dd683bc96f 100644
--- a/library/cpp/containers/comptrie/comptrie_builder.inl
+++ b/library/cpp/containers/comptrie/comptrie_builder.inl
@@ -453,10 +453,10 @@ bool TCompactTrieBuilder<T, D, S>::Find(const TSymbol* key, size_t keylen, TData
template <class T, class D, class S>
bool TCompactTrieBuilder<T, D, S>::FindLongestPrefix(
const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const {
- return Impl->FindLongestPrefix(key, keylen, prefixlen, value);
-}
-
-template <class T, class D, class S>
+ return Impl->FindLongestPrefix(key, keylen, prefixlen, value);
+}
+
+template <class T, class D, class S>
size_t TCompactTrieBuilder<T, D, S>::Save(IOutputStream& os) const {
return Impl->Save(os);
}
@@ -686,8 +686,8 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindEntryImpl(const
template <class T, class D, class S>
bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefix(
const TSymbol* key, size_t keylen, size_t* prefixlen, TData* value) const {
- using namespace NCompactTrie;
-
+ using namespace NCompactTrie;
+
if (!keylen) {
const char zero = '\0';
const bool ret = FindLongestPrefixImpl(&zero, 1, prefixlen, value);
@@ -703,14 +703,14 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefix(
*prefixlen = 0; // if we have found empty key, set prefixlen to zero
else if (!ret) // try to find value with empty key, because empty key is prefix of a every key
ret = FindLongestPrefix(nullptr, 0, prefixlen, value);
-
+
if (ret && prefixlen)
*prefixlen /= sizeof(TSymbol);
-
+
return ret;
- }
+ }
}
-
+
template <class T, class D, class S>
bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefixImpl(const char* keyptr, size_t keylen, size_t* prefixLen, TData* value) const {
const TNode* node = Root;
@@ -722,24 +722,24 @@ bool TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::FindLongestPrefixImp
while (keyTail && (node = node->Subtree()->FindLongestPrefix(keyTail, value, endResult, Packer))) {
if (endResult) // no more ways to find prefix and prefix has been found
break;
-
+
if (node->IsFinal()) {
lastFinalNode = node;
lastFinalKeyTail = keyTail;
- }
- }
+ }
+ }
if (!endResult && lastFinalNode) {
- if (value)
+ if (value)
Packer.UnpackLeaf(lastFinalNode->GetPayload(), *value);
keyTail = lastFinalKeyTail;
endResult = true;
- }
+ }
if (endResult && prefixLen)
*prefixLen = keyTail ? key.size() - keyTail.size() : key.size();
return endResult;
-}
-
-template <class T, class D, class S>
+}
+
+template <class T, class D, class S>
void TCompactTrieBuilder<T, D, S>::TCompactTrieBuilderImpl::Clear() {
DestroyNode(Root);
Pool.Clear();