Skip to content

Commit

Permalink
Missing iterator wrappers in LayerStack.h
Browse files Browse the repository at this point in the history
Adding const and reverse iterator wrappers (TheCherno#169)
  • Loading branch information
Jack-Punter authored and LovelySanta committed Nov 23, 2019
1 parent a957b5b commit be33737
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Hazel/src/Hazel/Core/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ namespace Hazel {
dispatcher.Dispatch<WindowCloseEvent>(HZ_BIND_EVENT_FN(Application::OnWindowClose));
dispatcher.Dispatch<WindowResizeEvent>(HZ_BIND_EVENT_FN(Application::OnWindowResize));

for (auto it = m_LayerStack.end(); it != m_LayerStack.begin(); )
for (auto it = m_LayerStack.rbegin(); it != m_LayerStack.rend(); ++it)
{
(*--it)->OnEvent(e);
(*it)->OnEvent(e);
if (e.Handled)
break;
}
Expand Down
7 changes: 7 additions & 0 deletions Hazel/src/Hazel/Core/LayerStack.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ namespace Hazel {

std::vector<Layer*>::iterator begin() { return m_Layers.begin(); }
std::vector<Layer*>::iterator end() { return m_Layers.end(); }
std::vector<Layer*>::reverse_iterator rbegin() { return m_Layers.rbegin(); }
std::vector<Layer*>::reverse_iterator rend() { return m_Layers.rend(); }

std::vector<Layer*>::const_iterator begin() const { return m_Layers.begin(); }
std::vector<Layer*>::const_iterator end() const { return m_Layers.end(); }
std::vector<Layer*>::const_reverse_iterator rbegin() const { return m_Layers.rbegin(); }
std::vector<Layer*>::const_reverse_iterator rend() const { return m_Layers.rend(); }
private:
std::vector<Layer*> m_Layers;
unsigned int m_LayerInsertIndex = 0;
Expand Down

0 comments on commit be33737

Please sign in to comment.