diff --git a/src/lib/iter-source.hpp b/src/lib/iter-source.hpp index 402cadb7d..8649ffc6e 100644 --- a/src/lib/iter-source.hpp +++ b/src/lib/iter-source.hpp @@ -268,7 +268,8 @@ namespace lib { protected: - IT& wrappedIter() { return src_; } + IT& wrappedIter() { return src_; } + IT const& wrappedIter() const { return src_; } }; diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index 889e4c75c..449f840cc 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -804,6 +804,7 @@ namespace lib { ~ChildExpandableSource() { } ///< @note mix-in interface, not meant to handle objects public: virtual VAL* expandChildren() =0; + virtual size_t depth() const =0; }; /** @@ -832,6 +833,12 @@ namespace lib { return Parent::wrappedIter()? & *Parent::wrappedIter() ///////////////////////////////////TICKET #1125 : trickery to cope with the misaligned IterSource design : nullptr; } + + virtual size_t + depth() const override + { + return Parent::wrappedIter().depth(); + } }; }//(End)Iterator decorating layer implementation @@ -861,6 +868,8 @@ namespace lib { struct IterExploreSource : IterSource::iterator { + using Expandable = iter_explorer::ChildExpandableSource; + IterExploreSource() =default; // inherited default copy operations @@ -869,16 +878,15 @@ namespace lib { void expandChildren() { - using Expandable = iter_explorer::ChildExpandableSource; - - if (not this->source()) - throw error::State ("operating on a disabled default constructed TreeExplorer" - ,error::LUMIERA_ERROR_BOTTOM_VALUE); - - auto source = this->source().get(); - VAL* changedResult = dynamic_cast (source)->expandChildren(); + VAL* changedResult = expandableSource().expandChildren(); this->resetPos (changedResult); ///////////////////////////////////TICKET #1125 : trickery to cope with the misaligned IterSource design } + + size_t + depth() const + { + return expandableSource().depth(); + } private: @@ -892,6 +900,17 @@ namespace lib { new iter_explorer::PackagedTreeExplorerSource { move (opaqueSrcPipeline)})} { } + + Expandable& + expandableSource() const + { + if (not this->source()) + throw error::State ("operating on a disabled default constructed TreeExplorer" + ,error::LUMIERA_ERROR_BOTTOM_VALUE); + + auto source = unConst(this)->source().get(); + return dynamic_cast (*source); + } }; diff --git a/tests/library/iter-tree-explorer-test.cpp b/tests/library/iter-tree-explorer-test.cpp index c8ae64a26..7b0be788d 100644 --- a/tests/library/iter-tree-explorer-test.cpp +++ b/tests/library/iter-tree-explorer-test.cpp @@ -929,47 +929,66 @@ namespace test{ { DataSrc& src; string& toFind; - uint pos; vector protocol; State(DataSrc& s, string& t) : src{s} , toFind{t} - , pos{0} , protocol{0} { } - bool checkPoint() const { return src; } - State& yield() const { return *unConst(this); } - void iterNext() { ++src; ++protocol.back(); } + bool + checkPoint() const + { + return src; + } + + State& + yield() const + { + return *unConst(this); + } + + void + iterNext() + { + ++src; + protocol.resize (1+src.depth()); + ++protocol.back(); + } + + void + expandChildren() + { + src.expandChildren(); + } + + bool + isMatch() const + { + ASSERT (src.depth() < toFind.size()); + return *src == toFind[src.depth()]; + } }; + // Layer-3: Evaluation pipeline to drive search string toFind = util::join (treeExplore (RandomSeq{5}), ""); cout << "Search in random tree: toFind = "<pos < it->toFind.size() - 1 - and *(it->src) == it->toFind[it->pos]) + while (it->src.depth() < it->toFind.size() - 1 + and it->isMatch()) { cout <<"|!| expand "<protocol)<expandChildren(); cout <<"|.| "<<*(it->src)<<" -->> "<protocol)<src) == it->toFind[it->pos]) +// return it->isMatch(); + if (it->isMatch()) return true; else { cout << "|↯| "<<*(it->src)<< " ... " <protocol)< - - + + @@ -6230,16 +6230,108 @@ + + + + + + +

+ an welcher Stelle wird diese Mechanik +

+

+ an einen bestehenden Iterator angeschlossen +

+ + +
+
- + + + + + + + + + + + + + + + - + + + + + + + + + + +

+ Stichwort HierarchyOrientationIndicator +

+

+ +

+

+ ...will sagen, bin nun schon mehrfach in dieses Problem gelaufen, +

+

+ nachdem ich dachte, alles so schön gelöst zu haben. +

+

+ Das Problem ist, daß eben auch der Konsument irgendwie +

+

+ von den verschachtelten Strukturen mit gesteuert wird. +

+

+ Das Ergebnis ist eben nicht rein linear. +

+ + +
+
+ + + + + + + + + + +

+ ...das ist nämlich der triviale Workaround +

+ + +
+
+ + + + + + +
+
+
+
+ @@ -7158,6 +7250,148 @@
+ + + + + + + + + + + + + + + +

+ rLet(40878 < 18446744073709551615) → S +

+

+ |↯| S ... 40878 +

+

+ rLet(40879 < 18446744073709551615) → F +

+

+ |!| expand 40879 +

+

+ rLet(0 < 4) → A +

+

+ rLet(40880 < 18446744073709551615) → Q +

+

+ |.| A -->> 40879 +

+

+ |!| expand 40879 +

+

+ rLet(0 < 4) → F +

+

+ rLet(1 < 4) → N +

+

+ |.| F -->> 40879 +

+

+ |↯| F ... 40879 +

+

+ rLet(1 < 4) → W +

+

+ |↯| W ... 40879-0-1 +

+

+ rLet(2 < 4) → N +

+

+ |↯| N ... 40879-0-2 +

+

+ rLet(3 < 4) → T +

+

+ |↯| T ... 40879-0-3 +

+

+ rLet(4 < 4) → F +

+

+ |↯| N ... 40879-1 +

+

+ rLet(2 < 4) → F +

+

+ |↯| F ... 40879-2 +

+

+ rLet(3 < 4) → A +

+

+ |!| expand 40879-3 +

+

+ rLet(0 < 4) → J +

+

+ rLet(4 < 4) → Y +

+

+ |.| J -->> 40879-3 +

+

+ |↯| J ... 40879-3 +

+

+ rLet(1 < 4) → H +

+

+ |↯| H ... 40879-4 +

+

+ rLet(2 < 4) → H +

+

+ |↯| H ... 40879-5 +

+

+ rLet(3 < 4) → F +

+

+ |↯| F ... 40879-6 +

+

+ rLet(4 < 4) → V +

+

+ |↯| Q ... 40880 +

+

+ rLet(40881 < 18446744073709551615) → A +

+

+ |↯| A ... 40881 +

+

+ rLet(40882 < 18446744073709551615) → X +

+

+ |↯| X ... 40882 +

+ + +
+
+ + +