From b8f7f6081fb2bb4462a0bedf9b9245f525c36154 Mon Sep 17 00:00:00 2001 From: kgv Date: Mon, 17 Sep 2018 13:14:00 +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 91e2da2ee3..09f6c29366 100644 --- a/src/NCollection/NCollection_Array1.hxx +++ b/src/NCollection/NCollection_Array1.hxx @@ -370,6 +370,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) { @@ -381,6 +384,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 b54df7efd5..7594290ac0 100755 --- a/src/NCollection/NCollection_Vector.hxx +++ b/src/NCollection/NCollection_Vector.hxx @@ -238,6 +238,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); @@ -273,6 +276,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.20.1