<commit_before>#ifndef _SoundManagerClass_
#define _SoundManagerClass_

#include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/Music.hpp>

#include <unordered_map>

class SoundManager
{
private:
    std::unordered_map<std::string, sf::SoundBuffer> soundBuffers;
    std::unordered_map<uint8_t, sf::Sound*> sounds;
    uint8_t soundId = 1;

    std::unordered_map<uint8_t, sf::Music*> musics;
    uint8_t musicId = 1;

protected:

public:
    SoundManager () {}

    ~SoundManager()
    {
        for (auto it = soundBuffers.begin(); it != soundBuffers.end(); soundBuffers.erase(it++)) {}
        for (auto it = sounds.begin(); it != sounds.end(); sounds.erase(it++)) {}
    }

    uint8_t playSound(const std::string& path, bool loop = false)
    {
        bool loaded = soundBuffers.count(path) > 0;
        sf::SoundBuffer& buffer = soundBuffers[path];

        if (!loaded)
        {
            if (!buffer.loadFromFile(path))
            {
                soundBuffers.erase(path);
                return 0;
            }
        }<commit_msg>clean memory<commit_after>#ifndef _SoundManagerClass_
#define _SoundManagerClass_

#include <SFML/Audio/SoundBuffer.hpp>
#include <SFML/Audio/Sound.hpp>
#include <SFML/Audio/Music.hpp>

#include <unordered_map>

class SoundManager
{
private:
    std::unordered_map<std::string, sf::SoundBuffer> soundBuffers;
    std::unordered_map<uint8_t, sf::Sound*> sounds;
    uint8_t soundId = 1;

    std::unordered_map<uint8_t, sf::Music*> musics;
    uint8_t musicId = 1;

protected:

public:
    SoundManager () {}

    ~SoundManager()
    {
        for (auto it = sounds.begin(); it != sounds.end(); sounds.erase(it++)) {
            delete it->second;
        }

        for (auto it = musics.begin(); it != musics.end(); musics.erase(it++)) {
            delete it->second;
        }
    }

    uint8_t playSound(const std::string& path, bool loop = false)
    {
        bool loaded = soundBuffers.count(path) > 0;
        sf::SoundBuffer& buffer = soundBuffers[path];

        if (!loaded)
        {
            if (!buffer.loadFromFile(path))
            {
                soundBuffers.erase(path);
                return 0;
            }
        }
{'fraction_non_alphanumeric': 0.13721973094170403, 'fraction_numerical': 0.008071748878923767, 'mean_word_length': 2.5925925925925926, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '5959900', 'n_tokens_mistral': 742, 'n_tokens_neox': 725, 'n_words': 143}