Library: add iteration capability to the Several-container
...and the nice thing is, the recently built `IterIndex` iteration wrapper covers this functionality right away, simply because `lib::Several` is a generic container with subscript operator.
This commit is contained in:
parent
a3e8579e4a
commit
66a1f6f8ab
4 changed files with 87 additions and 38 deletions
|
|
@ -29,7 +29,7 @@
|
|||
** as »Lumiera Forward Iterator«, the current access position can be retrieved directly
|
||||
** and it can be relocated to another valid index position; this implies also the ability
|
||||
** to re-set the iteration to the container's start. Optionally, a smart-ptr can be
|
||||
** embedded, allowing the handle also to owns and manage the data container.
|
||||
** embedded, allowing the handle also to own and manage the data container.
|
||||
**
|
||||
** @see IterIndex_test
|
||||
** @see iter-adapter.hpp
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
|
||||
#include "lib/nocopy.hpp"
|
||||
#include "lib/iter-adapter.hpp"
|
||||
#include "lib/iter-index.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
|
|
@ -180,17 +180,25 @@ namespace lib {
|
|||
return data_->subscript (idx);
|
||||
}
|
||||
|
||||
I const&
|
||||
operator[] (size_t idx) const
|
||||
{
|
||||
return const_cast<Several&>(*this).operator[] (idx);
|
||||
}
|
||||
|
||||
I& front() { return operator[] (0); }
|
||||
I& back() { return operator[] (data_? data_->cnt-1 : 0); }
|
||||
|
||||
using iterator = I*;
|
||||
using const_iterator = I const*;
|
||||
using iterator = lib::IterIndex<Several>;
|
||||
using const_iterator = lib::IterIndex<const Several>;
|
||||
|
||||
iterator begin() { UNIMPLEMENTED ("iteration"); }
|
||||
iterator end() { UNIMPLEMENTED ("iteration"); }
|
||||
const_iterator begin() const { UNIMPLEMENTED ("iteration"); }
|
||||
const_iterator end() const { UNIMPLEMENTED ("iteration"); }
|
||||
iterator begin() { return iterator{*this}; }
|
||||
iterator end() { return iterator{}; }
|
||||
const_iterator begin() const { return const_iterator{*this};}
|
||||
const_iterator end() const { return const_iterator{}; }
|
||||
|
||||
friend auto begin (Several& svl) { return svl.begin();}
|
||||
friend auto end (Several& svl) { return svl.end(); }
|
||||
friend auto begin (Several const& svl) { return svl.begin();}
|
||||
friend auto end (Several const& svl) { return svl.end(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -127,12 +127,11 @@ namespace test{
|
|||
|
||||
|
||||
|
||||
/** @test verify the ability of IterCursor to switch
|
||||
* the direction of the iteration. This "gear switch" can be done
|
||||
* any time, while in the middle of iteration, and even after
|
||||
* iteration end. That means, even an exhausted iterator can be
|
||||
* "turned back". This does not work on a default constructed
|
||||
* IterCursor, though.
|
||||
/** @test verify the ability of IterIndex to access and manipulate
|
||||
* the current index position, which can be done any time, while in
|
||||
* the middle of iteration, and even after iteration end. That means,
|
||||
* even an exhausted iterator can be „reanimated“. This manipulation
|
||||
* is not allowed on a default constructed IterIndex, though.
|
||||
*/
|
||||
void
|
||||
verify_randomAccess ()
|
||||
|
|
@ -173,12 +172,17 @@ namespace test{
|
|||
CHECK (9 == iter.getIDX());
|
||||
VERIFY_ERROR (INDEX_BOUNDS, iter.setIDX(-1));
|
||||
CHECK (9 == iter.getIDX());
|
||||
|
||||
Iter empty;
|
||||
CHECK (isnil (empty));
|
||||
VERIFY_ERROR (INDEX_BOUNDS, empty.setIDX(0));
|
||||
VERIFY_ERROR (ITER_EXHAUST, empty.getIDX());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** @test verify the const and dereferencing variants,
|
||||
* based on the const-ness of the underlying STL iterator
|
||||
/** @test verify possible variations of this iterator template,
|
||||
* using a const container or maintaining shared ownership.
|
||||
*/
|
||||
void
|
||||
iterTypeVariations ()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<map version="1.0.1">
|
||||
<!-- To view this file, download free mind mapping software FreeMind from http://freemind.sourceforge.net -->
|
||||
<node BACKGROUND_COLOR="#6666ff" CREATED="1434127882200" ID="ID_1452170048" MODIFIED="1680365898333" STYLE="fork" TEXT="Lumi">
|
||||
<node BACKGROUND_COLOR="#6666ff" CREATED="1434127882200" ID="ID_1452170048" MODIFIED="1718038734570" STYLE="fork" TEXT="Lumi">
|
||||
<font NAME="SansSerif" SIZE="25"/>
|
||||
<node CREATED="1434128046296" FOLDED="true" ID="ID_1900827283" MODIFIED="1679363052358" POSITION="right" TEXT="GUI">
|
||||
<font BOLD="true" NAME="SansSerif" SIZE="14"/>
|
||||
|
|
@ -81854,9 +81854,37 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717797674913" ID="ID_1290234834" MODIFIED="1717797679937" TEXT="Iteration">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717797702893" ID="ID_1535587090" MODIFIED="1717797708437" TEXT="Layout">
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1717797674913" ID="ID_1290234834" MODIFIED="1718038739053" TEXT="Iteration">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1717797702893" ID="ID_1535587090" MODIFIED="1718040020040" TEXT="Layout">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1718038819461" ID="ID_834949267" MODIFIED="1718038892881" TEXT="wird wohl eine State-Core-Impl">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
ein einfacher Pointer geht nicht, wegen dem anzuwendenden Spread
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
</richcontent>
|
||||
</node>
|
||||
<node CREATED="1718039111176" ID="ID_679646830" MODIFIED="1718039131276" TEXT="sowas habe ich doch erst kürzlich implementiert....">
|
||||
<icon BUILTIN="smiley-neutral"/>
|
||||
<node CREATED="1718039133203" ID="ID_447868331" MODIFIED="1718039139678" TEXT="iter-index.hpp">
|
||||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#dcd790" COLOR="#690f4e" CREATED="1718039963580" ID="ID_1826313973" MODIFIED="1718040003556" TEXT="hey ... funktioniert out-of-the-box">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
</node>
|
||||
<node COLOR="#435e98" CREATED="1718040021121" ID="ID_63571029" MODIFIED="1718040026770" TEXT="gekauft">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1718040049417" ID="ID_360730872" MODIFIED="1718040052952" TEXT="einbauen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717797709076" ID="ID_1453437458" MODIFIED="1717797713403" TEXT="const-Iterator">
|
||||
|
|
@ -81918,7 +81946,7 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<node CREATED="1716909012702" ID="ID_1876994172" MODIFIED="1716909016713" TEXT="const-correctness">
|
||||
<node CREATED="1716909019405" ID="ID_1406909807" MODIFIED="1716909042294" TEXT="ein const Several<X> ist ein Several<const X>"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1717594749496" ID="ID_390432519" MODIFIED="1717594763711" TEXT="Allokator-Problem gewaltsam lösen">
|
||||
<node BACKGROUND_COLOR="#c8c0b6" COLOR="#ff0000" CREATED="1717594749496" ID="ID_390432519" MODIFIED="1718038723473" TEXT="Allokator-Problem gewaltsam lösen">
|
||||
<icon BUILTIN="yes"/>
|
||||
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1717594765625" ID="ID_1189594619" MODIFIED="1717594883249" TEXT="das Problem">
|
||||
<linktarget COLOR="#982b52" DESTINATION="ID_1189594619" ENDARROW="Default" ENDINCLINATION="-919;-125;" ID="Arrow_ID_1251242601" SOURCE="ID_891863283" STARTARROW="None" STARTINCLINATION="338;767;"/>
|
||||
|
|
@ -81963,11 +81991,11 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#f8f1cb" COLOR="#a50125" CREATED="1717595132644" ID="ID_450689056" MODIFIED="1717595604710" TEXT="spezielle Probleme verbleiben...">
|
||||
<node COLOR="#435e98" CREATED="1717595132644" ID="ID_450689056" MODIFIED="1718038718704" TEXT="spezielle Probleme verbleiben...">
|
||||
<icon BUILTIN="messagebox_warning"/>
|
||||
<node CREATED="1717595496517" ID="ID_1721370451" MODIFIED="1717595511854" TEXT="man muß einen Funktions-Pointer auf eine Delete-Funktion bereitstellen"/>
|
||||
<node CREATED="1717595512394" ID="ID_1248004805" MODIFIED="1717595535123" TEXT="diese Funktion muß „irgendwo residieren“"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717595555989" ID="ID_1131600026" MODIFIED="1717595597589" TEXT="⟹ erkennen ob diese Funktion statisch bereitstellbar ist">
|
||||
<node COLOR="#435e98" CREATED="1717595555989" ID="ID_1131600026" MODIFIED="1718038714590" TEXT="⟹ erkennen ob diese Funktion statisch bereitstellbar ist">
|
||||
<font NAME="SansSerif" SIZE="12"/>
|
||||
<icon BUILTIN="yes"/>
|
||||
<node CREATED="1717595622928" ID="ID_674949727" MODIFIED="1717595800427" TEXT="Kriterium: der Allokator hat (k)eine eigene Identität">
|
||||
|
|
@ -82018,17 +82046,25 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
<icon BUILTIN="idea"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1717596235650" ID="ID_608819565" MODIFIED="1717717682157" TEXT="Implementierung">
|
||||
<node COLOR="#338800" CREATED="1717596235650" ID="ID_608819565" MODIFIED="1718038596908" TEXT="Implementierung">
|
||||
<linktarget COLOR="#549cbc" DESTINATION="ID_608819565" ENDARROW="Default" ENDINCLINATION="152;866;" ID="Arrow_ID_190880203" SOURCE="ID_492608922" STARTARROW="None" STARTINCLINATION="-139;-10;"/>
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717596241009" ID="ID_770727824" MODIFIED="1717596250200" TEXT="Erkennungs-Mechanismus">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<icon BUILTIN="hourglass"/>
|
||||
<node BACKGROUND_COLOR="#e0ceaa" COLOR="#690f14" CREATED="1718038613010" ID="ID_613483908" MODIFIED="1718038630640" TEXT="vorerst KISS-implementiert mit std::function">
|
||||
<icon BUILTIN="ksmiletris"/>
|
||||
<node CREATED="1718038633031" ID="ID_602178278" MODIFIED="1718038661775" TEXT="das macht die ganze mühsame Arbeit für uns..."/>
|
||||
<node BACKGROUND_COLOR="#ede19d" COLOR="#a50125" CREATED="1718038662411" ID="ID_140257212" MODIFIED="1718038704941" TEXT="aber verschwendet Platz ⟹ später verbessern">
|
||||
<icon BUILTIN="yes"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717596251272" ID="ID_33871958" MODIFIED="1717596257784" TEXT="statisches Trampolin">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717596259159" ID="ID_1839960110" MODIFIED="1717596303613" TEXT="einmal-Funktor">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1717596241009" ID="ID_770727824" MODIFIED="1718038586173" TEXT="Erkennungs-Mechanismus">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1717596251272" ID="ID_33871958" MODIFIED="1718038586174" TEXT="statisches Trampolin">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#d2beaf" COLOR="#5c4d6e" CREATED="1717596259159" ID="ID_1839960110" MODIFIED="1718038586173" TEXT="einmal-Funktor">
|
||||
<icon BUILTIN="hourglass"/>
|
||||
<node COLOR="#435e98" CREATED="1717596309134" ID="ID_239011587" MODIFIED="1717596403567" TEXT="sowas hab ich doch erst kürzlich implementiert....">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head/>
|
||||
|
|
@ -82418,17 +82454,18 @@ Date:   Thu Apr 20 18:53:17 2023 +0200<br/>
|
|||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717777101317" ID="ID_826816346" MODIFIED="1717777105434" TEXT="konkret einbinden">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717777109755" ID="ID_1395035594" MODIFIED="1717777115683" TEXT="neue Elemente erstellen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717777153193" ID="ID_626770308" MODIFIED="1717777157073" TEXT="Element-Typ">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eef0c5" COLOR="#990000" CREATED="1717777109755" ID="ID_1395035594" MODIFIED="1718038551155" TEXT="neue Elemente erstellen">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1717777153193" ID="ID_626770308" MODIFIED="1718038519856" TEXT="Element-Typ">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1718038522062" ID="ID_380204485" LINK="#ID_1037000737" MODIFIED="1718038545847" TEXT="getestet"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717777157905" ID="ID_1190162917" MODIFIED="1717777164089" TEXT="beliebiger Typ">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1717777167167" ID="ID_893092417" MODIFIED="1717777178595" TEXT="hier die Einschränkungen korrekt einarbeiten">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node COLOR="#338800" CREATED="1717777167167" ID="ID_893092417" MODIFIED="1718038515333" TEXT="Festlegung auf die korrekte Destruktor-Variante">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1717777223888" ID="ID_1213625055" MODIFIED="1717777230003" TEXT="die wild-move-Flag"/>
|
||||
<node CREATED="1717777223888" ID="ID_1213625055" MODIFIED="1718038486239" TEXT="die wild-move-Sperre ggfs setzen"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#fdfdcf" COLOR="#ff0000" CREATED="1717777186269" ID="ID_473170944" MODIFIED="1717777213678" TEXT="can Destroy?">
|
||||
<icon BUILTIN="flag-pink"/>
|
||||
|
|
|
|||
Loading…
Reference in a new issue