File indexing completed on 2025-01-18 10:04:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef NCollection_Iterator_HeaderFile
0015 #define NCollection_Iterator_HeaderFile
0016
0017 #include <Standard_Assert.hxx>
0018 #include <iterator>
0019
0020
0021
0022
0023
0024
0025
0026 template<class Container>
0027 class NCollection_Iterator
0028 {
0029 public:
0030
0031 NCollection_Iterator() : myCur(typename Container::iterator()), myLast(typename Container::iterator()) {}
0032
0033 NCollection_Iterator(const NCollection_Iterator& theOther) : myCur(theOther.myCur), myLast(theOther.myLast) {}
0034
0035 NCollection_Iterator(const Container& theList) : myCur(const_cast<Container&>(theList).begin()), myLast(const_cast<Container&>(theList).end()) {}
0036
0037 NCollection_Iterator(const Container& theList, const typename Container::iterator& theOther)
0038 : myCur(theOther), myLast(const_cast<Container&>(theList).end()) {}
0039
0040 NCollection_Iterator(const Container& theList, typename Container::iterator&& theOther)
0041 : myCur(theOther), myLast(const_cast<Container&>(theList).end())
0042 {}
0043
0044 ~NCollection_Iterator() {}
0045
0046 void Init(Container& theList)
0047 {
0048 myCur = theList.begin();
0049 myLast = theList.end();
0050 }
0051
0052 void Init(const Container& theList)
0053 {
0054 Init(const_cast<Container&>(theList));
0055 }
0056
0057 virtual bool More() const
0058 {
0059 return myCur != myLast;
0060 }
0061
0062 void Initialize(Container& theList)
0063 {
0064 Init(theList);
0065 }
0066
0067 void Initialize(const Container& theList)
0068 {
0069 Init(theList);
0070 }
0071
0072 const typename Container::iterator& ValueIter() const
0073 {
0074 return myCur;
0075 }
0076
0077 typename Container::iterator& ChangeValueIter()
0078 {
0079 return myCur;
0080 }
0081
0082 const typename Container::iterator& EndIter() const
0083 {
0084 return myLast;
0085 }
0086
0087 typename Container::iterator& ChangeEndIter()
0088 {
0089 return myLast;
0090 }
0091
0092 virtual void Next()
0093 {
0094 ++(myCur);
0095 }
0096
0097 const typename Container::const_reference Value() const
0098 {
0099 return *myCur;
0100 }
0101
0102 const typename Container::reference ChangeValue()
0103 {
0104 return *myCur;
0105 }
0106
0107 bool operator==(const NCollection_Iterator& theOther) { return myLast == theOther.myLast && myCur == theOther.myCur; }
0108
0109 bool operator!=(const NCollection_Iterator& theOther) { return myLast != theOther.myLast || myCur != theOther.myCur; }
0110
0111 NCollection_Iterator& operator=(const NCollection_Iterator& theOther)
0112 {
0113 if (this != &theOther)
0114 {
0115 myLast = theOther.myLast;
0116 myCur = theOther.myCur;
0117 }
0118 return *this;
0119 }
0120
0121 NCollection_Iterator& operator=(NCollection_Iterator&& theOther)
0122 {
0123 if (this != &theOther)
0124 {
0125 myLast = std::move(theOther.myLast);
0126 myCur = std::move(theOther.myCur);
0127 }
0128 return *this;
0129 }
0130
0131 private:
0132 typename Container::iterator myCur;
0133 typename Container::iterator myLast;
0134 };
0135
0136
0137 #endif