File indexing completed on 2026-07-27 09:43:42
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 NCollection_Iterator()
0031 : myCur(typename Container::iterator()),
0032 myLast(typename Container::iterator())
0033 {
0034 }
0035
0036 NCollection_Iterator(const NCollection_Iterator& theOther)
0037 : myCur(theOther.myCur),
0038 myLast(theOther.myLast)
0039 {
0040 }
0041
0042 NCollection_Iterator(const Container& theList)
0043 : myCur(const_cast<Container&>(theList).begin()),
0044 myLast(const_cast<Container&>(theList).end())
0045 {
0046 }
0047
0048 NCollection_Iterator(const Container& theList, const typename Container::iterator& theOther)
0049 : myCur(theOther),
0050 myLast(const_cast<Container&>(theList).end())
0051 {
0052 }
0053
0054 NCollection_Iterator(const Container& theList, typename Container::iterator&& theOther)
0055 : myCur(theOther),
0056 myLast(const_cast<Container&>(theList).end())
0057 {
0058 }
0059
0060 ~NCollection_Iterator() {}
0061
0062 void Init(Container& theList)
0063 {
0064 myCur = theList.begin();
0065 myLast = theList.end();
0066 }
0067
0068 void Init(const Container& theList) { Init(const_cast<Container&>(theList)); }
0069
0070 virtual bool More() const { return myCur != myLast; }
0071
0072 void Initialize(Container& theList) { Init(theList); }
0073
0074 void Initialize(const Container& theList) { Init(theList); }
0075
0076 const typename Container::iterator& ValueIter() const { return myCur; }
0077
0078 typename Container::iterator& ChangeValueIter() { return myCur; }
0079
0080 const typename Container::iterator& EndIter() const { return myLast; }
0081
0082 typename Container::iterator& ChangeEndIter() { return myLast; }
0083
0084 virtual void Next() { ++(myCur); }
0085
0086 const typename Container::const_reference Value() const { return *myCur; }
0087
0088 const typename Container::reference ChangeValue() { return *myCur; }
0089
0090 bool operator==(const NCollection_Iterator& theOther)
0091 {
0092 return myLast == theOther.myLast && myCur == theOther.myCur;
0093 }
0094
0095 bool operator!=(const NCollection_Iterator& theOther)
0096 {
0097 return myLast != theOther.myLast || myCur != theOther.myCur;
0098 }
0099
0100 NCollection_Iterator& operator=(const NCollection_Iterator& theOther)
0101 {
0102 if (this != &theOther)
0103 {
0104 myLast = theOther.myLast;
0105 myCur = theOther.myCur;
0106 }
0107 return *this;
0108 }
0109
0110 NCollection_Iterator& operator=(NCollection_Iterator&& theOther)
0111 {
0112 if (this != &theOther)
0113 {
0114 myLast = std::move(theOther.myLast);
0115 myCur = std::move(theOther.myCur);
0116 }
0117 return *this;
0118 }
0119
0120 private:
0121 typename Container::iterator myCur;
0122 typename Container::iterator myLast;
0123 };
0124
0125 #endif