File indexing completed on 2026-09-14 09:15:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 #ifndef NCollection_BaseList_HeaderFile
0026 #define NCollection_BaseList_HeaderFile
0027
0028 #include <Standard_NoSuchObject.hxx>
0029 #include <NCollection_DefineAlloc.hxx>
0030 #include <NCollection_ListNode.hxx>
0031
0032 #include <utility>
0033
0034 typedef void (*NCollection_DelListNode)(NCollection_ListNode*,
0035 occ::handle<NCollection_BaseAllocator>& theAl);
0036
0037
0038 class NCollection_BaseList
0039 {
0040 public:
0041
0042 DEFINE_STANDARD_ALLOC
0043 DEFINE_NCOLLECTION_ALLOC
0044
0045 public:
0046 class Iterator
0047 {
0048 public:
0049
0050 Iterator() noexcept
0051 : myCurrent(nullptr),
0052 myPrevious(nullptr)
0053 {
0054 }
0055
0056
0057 Iterator(const NCollection_BaseList& theList) noexcept
0058 : myCurrent(theList.myFirst),
0059 myPrevious(nullptr)
0060 {
0061 }
0062
0063
0064 void Init(const NCollection_BaseList& theList) noexcept
0065 {
0066 myCurrent = theList.myFirst;
0067 myPrevious = nullptr;
0068 }
0069
0070
0071 void Initialize(const NCollection_BaseList& theList) noexcept { Init(theList); }
0072
0073
0074 bool More() const noexcept { return (myCurrent != nullptr); }
0075
0076
0077 bool operator==(const Iterator& theIt) const noexcept { return myCurrent == theIt.myCurrent; }
0078
0079
0080 bool IsEqual(const Iterator& theOther) const noexcept { return *this == theOther; }
0081
0082 protected:
0083 void Init(const NCollection_BaseList& theList, NCollection_ListNode* const thePrev) noexcept
0084 {
0085 myCurrent = thePrev ? thePrev->Next() : (NCollection_ListNode*)theList.PLast();
0086 myPrevious = thePrev;
0087 }
0088
0089 public:
0090 NCollection_ListNode* myCurrent;
0091 NCollection_ListNode* myPrevious;
0092 friend class NCollection_BaseList;
0093 };
0094
0095 public:
0096
0097
0098
0099 int Extent() const noexcept { return static_cast<int>(myLength); }
0100
0101
0102 int Length() const noexcept { return static_cast<int>(myLength); }
0103
0104
0105 size_t Size() const noexcept { return myLength; }
0106
0107
0108
0109 bool IsEmpty() const noexcept { return (myFirst == nullptr); }
0110
0111
0112
0113 const occ::handle<NCollection_BaseAllocator>& Allocator() const noexcept { return myAllocator; }
0114
0115
0116
0117 virtual ~NCollection_BaseList() = default;
0118
0119 protected:
0120
0121
0122
0123
0124 NCollection_BaseList(const occ::handle<NCollection_BaseAllocator>& theAllocator = nullptr)
0125 : myFirst(nullptr),
0126 myLast(nullptr),
0127 myLength(0)
0128 {
0129 myAllocator =
0130 (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
0131 }
0132
0133
0134
0135 Standard_EXPORT void PClear(NCollection_DelListNode fDel);
0136
0137
0138
0139 const NCollection_ListNode* PFirst() const noexcept { return myFirst; }
0140
0141
0142
0143 const NCollection_ListNode* PLast() const noexcept { return myLast; }
0144
0145
0146
0147 Standard_EXPORT void PAppend(NCollection_ListNode* theNode) noexcept;
0148
0149
0150
0151 void PAppend(NCollection_ListNode* theNode, Iterator& theIt) noexcept
0152 {
0153 NCollection_ListNode* aPrev = myLast;
0154 PAppend(theNode);
0155 theIt.Init(*this, aPrev);
0156 }
0157
0158
0159
0160 Standard_EXPORT void PAppend(NCollection_BaseList& theOther) noexcept;
0161
0162
0163
0164 Standard_EXPORT void PPrepend(NCollection_ListNode* theNode) noexcept;
0165
0166
0167
0168 Standard_EXPORT void PPrepend(NCollection_BaseList& theOther) noexcept;
0169
0170
0171
0172 Standard_EXPORT void PRemoveFirst(NCollection_DelListNode fDel);
0173
0174
0175
0176 Standard_EXPORT void PRemove(Iterator& theIter, NCollection_DelListNode fDel);
0177
0178
0179
0180 Standard_EXPORT void PInsertBefore(NCollection_ListNode* theNode, Iterator& theIter);
0181
0182
0183
0184 Standard_EXPORT void PInsertBefore(NCollection_BaseList& theOther, Iterator& theIter);
0185
0186
0187
0188 Standard_EXPORT void PInsertAfter(NCollection_ListNode* theNode, Iterator& theIter);
0189
0190
0191
0192 Standard_EXPORT void PInsertAfter(NCollection_BaseList& theOther, Iterator& theIter);
0193
0194
0195
0196 Standard_EXPORT void PReverse() noexcept;
0197
0198
0199
0200
0201
0202 void PExchange(NCollection_BaseList& theOther) noexcept
0203 {
0204 std::swap(myAllocator, theOther.myAllocator);
0205 std::swap(myFirst, theOther.myFirst);
0206 std::swap(myLast, theOther.myLast);
0207 std::swap(myLength, theOther.myLength);
0208 }
0209
0210 protected:
0211
0212 occ::handle<NCollection_BaseAllocator> myAllocator;
0213 NCollection_ListNode* myFirst;
0214 NCollection_ListNode* myLast;
0215 size_t myLength;
0216
0217
0218 friend class Iterator;
0219 };
0220
0221 #endif