From 27ff478ea44f0e045f97a800a7c10da1703b2cbe Mon Sep 17 00:00:00 2001 From: oan Date: Mon, 16 Jan 2023 14:58:52 +0300 Subject: [PATCH] 0030143: Foundation Classes - provide operator[] alias for NCollection_Array1, NCollection_Vector --- src/NCollection/NCollection_Array1.hxx | 6 ++++++ src/NCollection/NCollection_Vector.hxx | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/NCollection/NCollection_Array1.hxx b/src/NCollection/NCollection_Array1.hxx index 32e9e7f491..04482c2c02 100644 --- a/src/NCollection/NCollection_Array1.hxx +++ b/src/NCollection/NCollection_Array1.hxx @@ -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) diff --git a/src/NCollection/NCollection_Vector.hxx b/src/NCollection/NCollection_Vector.hxx index 410d4db565..04660e3488 100755 --- a/src/NCollection/NCollection_Vector.hxx +++ b/src/NCollection/NCollection_Vector.hxx @@ -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); -- 2.39.5