CObjectList: Provide operator== for iterators

Makes the interface logically symmetrical in terms of allowed
comparisons.
This commit is contained in:
Lioncash 2020-05-07 08:25:53 -04:00
parent 762a4634cb
commit 2014854f7c
1 changed files with 4 additions and 2 deletions

View File

@ -44,7 +44,8 @@ public:
m_id = m_list.GetNextObjectIndex(m_id); m_id = m_list.GetNextObjectIndex(m_id);
return *this; return *this;
} }
bool operator!=(const iterator& other) const { return m_id != other.m_id; } bool operator==(const iterator& other) const { return m_id == other.m_id; }
bool operator!=(const iterator& other) const { return !operator==(other); }
CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); } CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
}; };
@ -59,7 +60,8 @@ public:
m_id = m_list.GetNextObjectIndex(m_id); m_id = m_list.GetNextObjectIndex(m_id);
return *this; return *this;
} }
bool operator!=(const iterator& other) const { return m_id != other.m_id; } bool operator==(const iterator& other) const { return m_id == other.m_id; }
bool operator!=(const iterator& other) const { return !operator==(other); }
const CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); } const CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
}; };