Skip to content

Commit b521806

Browse files
authored
Merge pull request #384 from Libvisual/add-palette-iteration-comparison-api
Add LV::Palette methods for iterations and comparisons.
2 parents d937b13 + a530883 commit b521806

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

libvisual/libvisual/lv_palette.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ namespace LV {
4545
//!
4646
struct LV_API Palette
4747
{
48+
using const_iterator = std::vector<Color>::const_iterator;
49+
using iterator = std::vector<Color>::iterator;
50+
4851
std::vector<Color> colors;
4952

5053
/**
@@ -70,6 +73,46 @@ namespace LV {
7073
return *this;
7174
}
7275

76+
constexpr friend bool operator== (Palette const& lhs, Palette const& rhs)
77+
{
78+
return lhs.colors == rhs.colors;
79+
}
80+
81+
constexpr friend bool operator!= (Palette const& lhs, Palette const& rhs)
82+
{
83+
return !(lhs == rhs);
84+
}
85+
86+
constexpr const_iterator cbegin () const noexcept
87+
{
88+
return colors.cbegin ();
89+
}
90+
91+
constexpr const_iterator cend () const noexcept
92+
{
93+
return colors.cend ();
94+
}
95+
96+
constexpr const_iterator begin () const noexcept
97+
{
98+
return colors.begin ();
99+
}
100+
101+
constexpr const_iterator end () const noexcept
102+
{
103+
return colors.end ();
104+
}
105+
106+
constexpr iterator begin () noexcept
107+
{
108+
return colors.begin ();
109+
}
110+
111+
constexpr iterator end () noexcept
112+
{
113+
return colors.end ();
114+
}
115+
73116
bool empty () const
74117
{
75118
return colors.empty ();

0 commit comments

Comments
 (0)