From 9d0f64b1b7d7331f6b06b43ac8e9d3e2024afaed Mon Sep 17 00:00:00 2001 From: Chong Kai Xiong Date: Fri, 24 Jan 2025 01:50:07 +0800 Subject: [PATCH 1/2] Core (LV::Palette): Add comparison operators. --- libvisual/libvisual/lv_palette.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libvisual/libvisual/lv_palette.h b/libvisual/libvisual/lv_palette.h index 94d52e46b..3fd53f35c 100644 --- a/libvisual/libvisual/lv_palette.h +++ b/libvisual/libvisual/lv_palette.h @@ -70,6 +70,16 @@ namespace LV { return *this; } + constexpr friend bool operator== (Palette const& lhs, Palette const& rhs) + { + return lhs.colors == rhs.colors; + } + + constexpr friend bool operator!= (Palette const& lhs, Palette const& rhs) + { + return !(lhs == rhs); + } + bool empty () const { return colors.empty (); From a53088306257781d5eeb22bf0ee73f0377a6355f Mon Sep 17 00:00:00 2001 From: Chong Kai Xiong Date: Fri, 24 Jan 2025 05:39:15 +0800 Subject: [PATCH 2/2] Core (LV::Palette): Add methods for iteration. --- libvisual/libvisual/lv_palette.h | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libvisual/libvisual/lv_palette.h b/libvisual/libvisual/lv_palette.h index 3fd53f35c..c7e731a41 100644 --- a/libvisual/libvisual/lv_palette.h +++ b/libvisual/libvisual/lv_palette.h @@ -45,6 +45,9 @@ namespace LV { //! struct LV_API Palette { + using const_iterator = std::vector::const_iterator; + using iterator = std::vector::iterator; + std::vector colors; /** @@ -80,6 +83,36 @@ namespace LV { return !(lhs == rhs); } + constexpr const_iterator cbegin () const noexcept + { + return colors.cbegin (); + } + + constexpr const_iterator cend () const noexcept + { + return colors.cend (); + } + + constexpr const_iterator begin () const noexcept + { + return colors.begin (); + } + + constexpr const_iterator end () const noexcept + { + return colors.end (); + } + + constexpr iterator begin () noexcept + { + return colors.begin (); + } + + constexpr iterator end () noexcept + { + return colors.end (); + } + bool empty () const { return colors.empty ();