Merge pull request #319 from lioncash/object

CObjectList: Minor interface modifications
This commit is contained in:
Luke Street 2020-05-07 17:38:32 -04:00 committed by GitHub
commit 8aef93473e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 7 deletions

View File

@ -44,11 +44,10 @@ public:
m_id = m_list.GetNextObjectIndex(m_id);
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); }
};
iterator begin() { return iterator(*this, x2008_firstId); }
iterator end() { return iterator(*this, -1); }
class const_iterator {
friend class CObjectList;
@ -61,13 +60,19 @@ public:
m_id = m_list.GetNextObjectIndex(m_id);
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_iterator cbegin() const { return const_iterator(*this, x2008_firstId); }
const_iterator cend() const { return const_iterator(*this, -1); }
CObjectList(EGameObjectList listEnum);
[[nodiscard]] iterator begin() { return iterator(*this, x2008_firstId); }
[[nodiscard]] iterator end() { return iterator(*this, -1); }
[[nodiscard]] const_iterator begin() const { return const_iterator(*this, x2008_firstId); }
[[nodiscard]] const_iterator end() const { return const_iterator(*this, -1); }
[[nodiscard]] const_iterator cbegin() const { return const_iterator(*this, x2008_firstId); }
[[nodiscard]] const_iterator cend() const { return const_iterator(*this, -1); }
explicit CObjectList(EGameObjectList listEnum);
virtual ~CObjectList() = default;
void AddObject(CEntity& entity);