<commit_before>
#pragma once

#include "../deps.h"

#include "../entity/NBasic.h"

template <class T>
class NGroup : public NBasic {
private:
    int _freePosition = 0;

public:
    std::vector<T*> members;
    int memberCount = 0;
    int maxSize = 0;

    NGroup(int maxSize) {
        this->maxSize = maxSize;
    }

    T* add(T* obj) {
        this->members.push_back(obj);
        return obj;
    }

    T* remove(T* obj) {
        this->members.erase(std::remove(this->members.begin(), this->members.end(), obj),
            this->members.end());
        return obj;
    }

    virtual void render(SDL_Surface *surface) {
        for (T*& member: this->members) {
            if (member != nullptr && member->_exists) {
                member->render(surface);
            }
        }
    }
    
    virtual ~NGroup() {}
};<commit_msg>call destroy on group members<commit_after>
#pragma once

#include "../deps.h"

#include "../entity/NBasic.h"

template <class T>
class NGroup : public NBasic {
private:
    int _freePosition = 0;

public:
    std::vector<T*> members;
    int memberCount = 0;
    int maxSize = 0;

    NGroup(int maxSize) {
        this->maxSize = maxSize;
    }

    T* add(T* obj) {
        this->members.push_back(obj);
        return obj;
    }

    T* remove(T* obj) {
        this->members.erase(std::remove(this->members.begin(), this->members.end(), obj),
            this->members.end());
        return obj;
    }

    virtual void render(SDL_Surface *surface) {
        for (T*& member: this->members) {
            if (member != nullptr && member->_exists) {
                member->render(surface);
            }
        }
    }

    virtual void destroy() {
        // call destroy on all group members
        for (T*& member: this->members) {
            if (member != nullptr) { member->destroy(); }
        }

        NBasic::destroy();
    }
    
    virtual ~NGroup() {}
};
{'fraction_non_alphanumeric': 0.15059927045336113, 'fraction_numerical': 0.003126628452318916, 'mean_word_length': 1.9767441860465116, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 27, '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': '7613634', 'n_tokens_mistral': 618, 'n_tokens_neox': 599, 'n_words': 144}