Skip to content
Permalink
Browse files

Missing iterator wrappers in LayerStack.h

Adding const and reverse iterator wrappers (#169)
  • Loading branch information
Jack-Punter authored and LovelySanta committed Nov 23, 2019
1 parent a957b5b commit be33737454bf0993eb93bb374a3f12064825e5a2
Showing with 9 additions and 2 deletions.
  1. +2 −2 Hazel/src/Hazel/Core/Application.cpp
  2. +7 −0 Hazel/src/Hazel/Core/LayerStack.h
@@ -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;
}
@@ -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;

0 comments on commit be33737

Please sign in to comment.
You can’t perform that action at this time.