<commit_before>#include "LayeredPriorityRenderable.h"

LayeredPriorityRenderable::LayeredPriorityRenderable() {
	renderables = std::unique_ptr<std::multimap<uint32_t, std::shared_ptr<Renderable>>>(new std::multimap<uint32_t, std::shared_ptr<Renderable>>);
	setUp();
}

LayeredPriorityRenderable::~LayeredPriorityRenderable() {
	renderables.reset();
	tearDown();
}

void LayeredPriorityRenderable::setUp() {
}

void LayeredPriorityRenderable::_tearDown() {
	for (auto it = renderables->begin(); it != renderables->end(); ++it) {
		std::shared_ptr<Renderable> r = it->second;
		r->tearDown();
	}
}

void LayeredPriorityRenderable::tick() {
	for (auto it = renderables->begin(); it != renderables->end();) {
		std::shared_ptr<Renderable> r = it->second;
		if (r->isTornDown()) {
			it = renderables->erase(it);
		} else {
			r->tick();
			++it;
		}
	}
}

void LayeredPriorityRenderable::update() {
	for (auto it = renderables->begin(); it != renderables->end(); ++it) {
		std::shared_ptr<Renderable> r = it->second;
		r->update();
	}
}

void LayeredPriorityRenderable::attach(uint32_t priority, std::shared_ptr<Renderable> r) {
	renderables->insert(std::pair<uint32_t, std::shared_ptr<Renderable>>(priority, r));
}
<commit_msg>Don't forget to clear the depth buffer every time we switch priority<commit_after>#include "LayeredPriorityRenderable.h"

#define GLEW_STATIC
#include <GL/glew.h>

LayeredPriorityRenderable::LayeredPriorityRenderable() {
	renderables = std::unique_ptr<std::multimap<uint32_t, std::shared_ptr<Renderable>>>(new std::multimap<uint32_t, std::shared_ptr<Renderable>>);
	setUp();
}

LayeredPriorityRenderable::~LayeredPriorityRenderable() {
	renderables.reset();
	tearDown();
}

void LayeredPriorityRenderable::setUp() {
}

void LayeredPriorityRenderable::_tearDown() {
	for (auto it = renderables->begin(); it != renderables->end(); ++it) {
		std::shared_ptr<Renderable> r = it->second;
		r->tearDown();
	}
}

void LayeredPriorityRenderable::tick() {
	uint32_t prev = 0;
	for (auto it = renderables->begin(); it != renderables->end();) {
		uint32_t prio = it->first;
		std::shared_ptr<Renderable> r = it->second;
		if (prio != prev) glClear(GL_DEPTH_BUFFER_BIT);
		prev = prio;
		if (r->isTornDown()) {
			it = renderables->erase(it);
		} else {
			r->tick();
			++it;
		}
	}
}

void LayeredPriorityRenderable::update() {
	for (auto it = renderables->begin(); it != renderables->end(); ++it) {
		std::shared_ptr<Renderable> r = it->second;
		r->update();
	}
}

void LayeredPriorityRenderable::attach(uint32_t priority, std::shared_ptr<Renderable> r) {
	renderables->insert(std::pair<uint32_t, std::shared_ptr<Renderable>>(priority, r));
}

{'fraction_non_alphanumeric': 0.17450169236555096, 'fraction_numerical': 0.007897705904475368, 'mean_word_length': 6.287671232876712, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5374493', 'n_tokens_mistral': 997, 'n_tokens_neox': 957, 'n_words': 159}