File indexing completed on 2025-01-18 10:04:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef NCollection_BaseSequence_HeaderFile
0017 #define NCollection_BaseSequence_HeaderFile
0018
0019 #include <Standard.hxx>
0020 #include <NCollection_BaseAllocator.hxx>
0021 #include <NCollection_DefineAlloc.hxx>
0022
0023
0024
0025 class NCollection_SeqNode
0026 {
0027 public:
0028
0029 DEFINE_NCOLLECTION_ALLOC
0030 public:
0031 NCollection_SeqNode () : myNext (NULL), myPrevious (NULL) {}
0032 NCollection_SeqNode * Next () const { return myNext; }
0033 NCollection_SeqNode * Previous () const { return myPrevious; }
0034 void SetNext (NCollection_SeqNode * theNext) { myNext = theNext; }
0035 void SetPrevious (NCollection_SeqNode * thePrev) { myPrevious = thePrev; }
0036
0037 private:
0038 NCollection_SeqNode* myNext;
0039 NCollection_SeqNode* myPrevious;
0040 };
0041
0042 typedef void (* NCollection_DelSeqNode)
0043 (NCollection_SeqNode*, Handle(NCollection_BaseAllocator)& theAl);
0044
0045
0046
0047
0048
0049 class NCollection_BaseSequence
0050 {
0051 public:
0052
0053 DEFINE_STANDARD_ALLOC
0054 DEFINE_NCOLLECTION_ALLOC
0055
0056 public:
0057 class Iterator
0058 {
0059 public:
0060
0061 Iterator (void) : myCurrent (NULL), myPrevious(NULL) {}
0062
0063
0064 Iterator (const NCollection_BaseSequence& theSeq,
0065 const Standard_Boolean isStart)
0066 {
0067 Init (theSeq, isStart);
0068 }
0069
0070
0071 void Init (const NCollection_BaseSequence& theSeq,
0072 const Standard_Boolean isStart = Standard_True)
0073 {
0074 myCurrent = (isStart ? theSeq.myFirstItem : NULL);
0075 myPrevious = (isStart ? NULL : theSeq.myLastItem);
0076 }
0077
0078
0079 void Previous()
0080 {
0081 myCurrent = myPrevious;
0082 if (myCurrent)
0083 myPrevious = myCurrent->Previous();
0084 }
0085
0086 protected:
0087 NCollection_SeqNode* myCurrent;
0088 NCollection_SeqNode* myPrevious;
0089 friend class NCollection_BaseSequence;
0090 };
0091
0092 public:
0093
0094
0095 Standard_Boolean IsEmpty () const {return (mySize == 0);}
0096 Standard_Integer Length () const {return mySize;}
0097
0098
0099 const Handle(NCollection_BaseAllocator)& Allocator() const
0100 { return myAllocator; }
0101
0102 protected:
0103
0104
0105 NCollection_BaseSequence (const Handle(NCollection_BaseAllocator)& theAllocator) :
0106 myFirstItem (NULL),
0107 myLastItem (NULL),
0108 myCurrentItem (NULL),
0109 myCurrentIndex (0),
0110 mySize (0)
0111 {
0112 myAllocator = (theAllocator.IsNull() ? NCollection_BaseAllocator::CommonBaseAllocator() : theAllocator);
0113 }
0114
0115
0116 virtual ~NCollection_BaseSequence() {}
0117
0118 Standard_EXPORT void ClearSeq (NCollection_DelSeqNode fDel);
0119 Standard_EXPORT void PAppend (NCollection_SeqNode *);
0120 Standard_EXPORT void PAppend (NCollection_BaseSequence& S);
0121 Standard_EXPORT void PPrepend (NCollection_SeqNode *);
0122 Standard_EXPORT void PPrepend (NCollection_BaseSequence& S);
0123 Standard_EXPORT void PInsertAfter(Iterator& thePosition,
0124 NCollection_SeqNode *);
0125 Standard_EXPORT void PInsertAfter(const Standard_Integer Index,
0126 NCollection_SeqNode *);
0127 Standard_EXPORT void PInsertAfter(const Standard_Integer Index,
0128 NCollection_BaseSequence& S);
0129 Standard_EXPORT void PSplit (const Standard_Integer Index,
0130 NCollection_BaseSequence& Sub);
0131 Standard_EXPORT void RemoveSeq (Iterator& thePosition,
0132 NCollection_DelSeqNode fDel);
0133 Standard_EXPORT void RemoveSeq (const Standard_Integer Index,
0134 NCollection_DelSeqNode fDel);
0135 Standard_EXPORT void RemoveSeq (const Standard_Integer From,
0136 const Standard_Integer To,
0137 NCollection_DelSeqNode fDel);
0138 Standard_EXPORT void PReverse ();
0139 Standard_EXPORT void PExchange (const Standard_Integer I,
0140 const Standard_Integer J) ;
0141 Standard_EXPORT NCollection_SeqNode *
0142 Find (const Standard_Integer) const;
0143
0144 protected:
0145
0146
0147 Handle(NCollection_BaseAllocator) myAllocator;
0148 NCollection_SeqNode* myFirstItem;
0149 NCollection_SeqNode* myLastItem;
0150 NCollection_SeqNode* myCurrentItem;
0151 Standard_Integer myCurrentIndex;
0152 Standard_Integer mySize;
0153
0154 private:
0155
0156
0157 Standard_EXPORT NCollection_BaseSequence
0158 (const NCollection_BaseSequence& Other);
0159 void Nullify()
0160 {
0161 myFirstItem = myLastItem = myCurrentItem = NULL;
0162 myCurrentIndex = mySize = 0;
0163 }
0164
0165 friend class Iterator;
0166 };
0167
0168 #endif