]> OCCT Git - occt.git/commitdiff
0030143: Foundation Classes - provide operator[] alias for NCollection_Array1, NColle...
authoroan <oan@opencascade.com>
Mon, 16 Jan 2023 11:58:52 +0000 (14:58 +0300)
committeroan <oan@opencascade.com>
Mon, 16 Jan 2023 11:58:52 +0000 (14:58 +0300)
src/NCollection/NCollection_Array1.hxx
src/NCollection/NCollection_Vector.hxx

index 32e9e7f491ed94869d0afa39fa83fd470588c21f..04482c2c02072c1d5661c824c577db901770f451 100644 (file)
@@ -348,6 +348,9 @@ public:
   const TheItemType& operator() (const Standard_Integer theIndex) const
   { return Value (theIndex); }
 
+  //! operator[] - alias to Value
+  const TheItemType& operator[] (Standard_Integer theIndex) const { return Value (theIndex); }
+
   //! Variable value access
   TheItemType& ChangeValue (const Standard_Integer theIndex)
   {
@@ -359,6 +362,9 @@ public:
   TheItemType& operator() (const Standard_Integer theIndex)
   { return ChangeValue (theIndex); }
 
+  //! operator[] - alias to ChangeValue
+  TheItemType& operator[] (Standard_Integer theIndex) { return ChangeValue (theIndex); }
+
   //! Set value 
   void SetValue (const Standard_Integer theIndex,
                  const TheItemType&     theItem)
index 410d4db5650f7e922954bc981eb3f4caf14081c4..04660e34889ea85c73bbab5551c8d3d01652e278 100755 (executable)
@@ -231,6 +231,9 @@ public: //! @name public methods
     return Value (theIndex);
   }
 
+  //! Operator[] - query the const value
+  const TheItemType& operator[] (Standard_Integer theIndex) const { return Value (theIndex); }
+
   const TheItemType& Value (const Standard_Integer theIndex) const
   {
     return *(const TheItemType* )findV (theIndex);
@@ -266,6 +269,9 @@ public: //! @name public methods
     return ChangeValue (theIndex);
   }
 
+  //! Operator[] - query the value
+  TheItemType& operator[] ( Standard_Integer theIndex) { return ChangeValue (theIndex); }
+
   TheItemType& ChangeValue (const Standard_Integer theIndex)
   {
     return *(TheItemType* )findV (theIndex);