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

Method Forward

library/cpp/containers/comptrie/opaque_trie_iterator.cpp:29–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 }
28
29 bool TOpaqueTrieIterator::Forward() {
30 if (AtEmptyValue) {
31 AtEmptyValue = false;
32 bool res = Forward(); // TODO delete this after format change
33 if (res && MeasureNarrowKey() != 0) {
34 return res; // there was not "\0" key
35 }
36 // otherwise we are skipping "\0" key
37 }
38
39 if (!Trie.Length)
40 return false;
41
42 if (Forks.Empty()) {
43 TFork fork(Trie.Data, 0, Trie.Length, Trie.SkipFunction);
44 Forks.Push(fork);
45 } else {
46 TFork* topFork = &Forks.Top();
47 while (!topFork->NextDirection()) {
48 if (topFork->Node.GetOffset() >= Trie.Length)
49 return false;
50 Forks.Pop();
51 if (Forks.Empty())
52 return false;
53 topFork = &Forks.Top();
54 }
55 }
56
57 Y_ASSERT(!Forks.Empty());
58 while (Forks.Top().CurrentDirection != D_FINAL && !HasMaxKeyLength()) {
59 TFork nextFork = Forks.Top().NextFork(Trie.SkipFunction);
60 Forks.Push(nextFork);
61 }
62 TFork& top = Forks.Top();
63 static_assert(D_FINAL < D_NEXT, "relative order of NEXT and FINAL directions has changed");
64 if (HasMaxKeyLength() && top.CurrentDirection == D_FINAL && top.HasDirection(D_NEXT)) {
65 top.NextDirection();
66 }
67 return true;
68 }
69
70 bool TOpaqueTrieIterator::Backward() {
71 if (AtEmptyValue)

Callers 3

comptrie_trie.hFile · 0.45
operator++Method · 0.45
MakeStepMethod · 0.45

Calls 8

NextDirectionMethod · 0.80
NextForkMethod · 0.80
HasDirectionMethod · 0.80
EmptyMethod · 0.45
PushMethod · 0.45
TopMethod · 0.45
GetOffsetMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected