Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
BidirectionalIterator.h
Go to the documentation of this file.
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Traversal_BidirectionalIterator_h_
5#define _Stroika_Foundation_Traversal_BidirectionalIterator_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <iterator>
10
11#include "Stroika/Foundation/Common/Common.h"
12
13#include "Iterator.h"
14
15/**
16 *
17 * \file
18 * ****VERY ROUGH UNUSABLE DRAFT
19 *
20 * \note Code-Status: <a href="Code-Status.md#Draft">Draft</a>
21 *
22 */
23
24namespace Stroika::Foundation::Traversal {
25
26 /**
27 */
28 template <typename T, typename BASE_STD_ITERATOR = DefaultIteratorTraits<bidirectional_iterator_tag, T>>
29 class BidirectionalIterator : public Iterator<T, BASE_STD_ITERATOR> {
30 private:
31 using inherited = Iterator<T, BASE_STD_ITERATOR>;
32
33 public:
34 class IRep;
35
36 public:
37 using BidirectionalIteratorRepSharedPtr = unique_ptr<IRep>;
38
39 public:
40 /**
41 * \brief
42 * This overload is usually not called directly. Instead, iterators are
43 * usually created from a container (eg. Bag<T>::begin()).
44 *
45 * Iterators are safely copyable, preserving their current position.
46 *
47 * \pre RequireNotNull (rep.get ())
48 */
49 explicit BidirectionalIterator (const BidirectionalIteratorRepSharedPtr& rep);
50 BidirectionalIterator (const BidirectionalIterator& from);
51 BidirectionalIterator () = delete;
52
53 private:
54 /**
55 * Mostly internal type to select a constructor for the special END iterator.
56 */
57 enum ConstructionFlagForceAtEnd_ {
58 ForceAtEnd
59 };
60
61 private:
62 BidirectionalIterator (ConstructionFlagForceAtEnd_);
63
64 public:
65 /**
66 * \brief Iterators are safely copyable, preserving their current position.
67 */
68 nonvirtual BidirectionalIterator& operator= (const BidirectionalIterator& rhs) = default;
69
70 public:
71 // @todo add operator--
72
73 public:
74 /**
75 * \brief
76 * Used by *somecontainer*::end ()
77 *
78 * GetEmptyIterator () returns a special iterator which is always empty - always 'at the end'.
79 * This is handy in implementing STL-style 'if (a != b)' style iterator comparisons.
80 */
81 static BidirectionalIterator GetEmptyIterator ();
82 };
83
84 /**
85 */
86 template <typename T, typename BASE_STD_ITERATOR>
87 class BidirectionalIterator<T, BASE_STD_ITERATOR>::IRep : public Iterator<T, BASE_STD_ITERATOR>::IRep {
88 protected:
89 IRep () = default;
90 };
91
92}
93
94/*
95 ********************************************************************************
96 ******************************* Implementation Details *************************
97 ********************************************************************************
98 */
99
100#include "BidirectionalIterator.inl"
101
102#endif /*_Stroika_Foundation_Traversal_BidirectionalIterator_h_ */