From 075c64bebbdffdadafc7af3f41c39824fd83c6fe Mon Sep 17 00:00:00 2001 From: cutealien Date: Thu, 26 Aug 2021 16:41:14 +0000 Subject: [PATCH] Add equals and set_data functions to core::array for easier working with blocks of data. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6242 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 1 + include/irrArray.h | 43 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/changes.txt b/changes.txt index 04ee9dd8..00870ac7 100644 --- a/changes.txt +++ b/changes.txt @@ -1,5 +1,6 @@ -------------------------- Changes in 1.9 (not yet released) +- Add equals and set_data functions to core::array for easier working with blocks of data. - SIrrlichtCreationParameters::IgnoreInput set to false works again on X11. Thanks @ Victor Gaydov for report + patch + very good test cases! (bug #401) This had been broken since Irrlicht 1.6 diff --git a/include/irrArray.h b/include/irrArray.h index b8ffd705..b133b62d 100644 --- a/include/irrArray.h +++ b/include/irrArray.h @@ -231,6 +231,40 @@ public: free_when_destroyed=_free_when_destroyed; } + //! Set (copy) data from given memory block + /** \param newData data to set, must have newSize elements + \param newSize Amount of elements in newData + \param canShrink When true we reallocate the array even it can shrink. + May reduce memory usage, but call is more whenever size changes. + \param newDataIsSorted Info if you pass sorted/unsorted data + */ + void set_data(const T* newData, u32 newSize, bool newDataIsSorted=false, bool canShrink=false) + { + reallocate(newSize, canShrink); + set_used(newSize); + for ( u32 i=0; i& operator=(const array& other) { @@ -290,13 +323,7 @@ public: //! Equality operator bool operator == (const array& other) const { - if (used != other.used) - return false; - - for (u32 i=0; i