<commit_before>// =============================================================================
// Event Class for .NET Style Events
// by <NAME>
// February 18, 2010
// =============================================================================

#ifndef EVENT_HPP
#define EVENT_HPP

#include <vector>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include "Delegate.hpp"

template <typename T>
class Event
{
    typedef typename std::vector< Delegate<T>* >::iterator iter;
    public:
        void operator+=(Delegate<T>* delegate)
        {
            // An object can only subscribe once
            if (find(_delegates.begin(), _delegates.end(), delegate) == _delegates.end())
            {
                _delegates.push_back(delegate);
            }
        }
        void operator-=(Delegate<T>* delegate)
        {
            iter i = _delegates.begin();
            while (i != _delegates.end())
            {
                if (*i == delegate)
                {
                    i = _delegates.erase(i);
                }
                else
                {
                    ++i;
                }
            }
        }
        void operator()(T param)
        {
            for (iter i = _delegates.begin(); i != _delegates.end(); ++i)
            {
                if((*i) != NULL)
                (*i)->operator()(param);
            }
        }

        typename std::vector<Delegate<T>* >::size_type numDelegates()
        {
            return _delegates.size();
        }

    private:
        std::vector< Delegate<T>* > _delegates;
};

#endif<commit_msg>Adds Clear() to Event.<commit_after>// =============================================================================
// Event Class for .NET Style Events
// by <NAME>
// February 18, 2010
// =============================================================================

#ifndef EVENT_HPP
#define EVENT_HPP

#include <vector>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include "Delegate.hpp"

template <typename T>
class Event
{
    typedef typename std::vector< Delegate<T>* >::iterator iter;
    public:
        void operator+=(Delegate<T>* delegate)
        {
            // An object can only subscribe once
            if (find(_delegates.begin(), _delegates.end(), delegate) == _delegates.end())
            {
                _delegates.push_back(delegate);
            }
        }
        void operator-=(Delegate<T>* delegate)
        {
            iter i = _delegates.begin();
            while (i != _delegates.end())
            {
                if (*i == delegate)
                {
                    i = _delegates.erase(i);
                }
                else
                {
                    ++i;
                }
            }
        }
        void operator()(T param)
        {
            for (iter i = _delegates.begin(); i != _delegates.end(); ++i)
            {
                if((*i) != NULL)
                (*i)->operator()(param);
            }
        }

        typename std::vector<Delegate<T>* >::size_type numDelegates()
        {
            return _delegates.size();
        }

        void Clear()
        {
            _delegates.clear();
        }

    private:
        std::vector< Delegate<T>* > _delegates;
};

#endif
{'fraction_non_alphanumeric': 0.21435086652477958, 'fraction_numerical': 0.0036485253876558225, 'mean_word_length': 1.6152623211446742, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 33, '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': '4597304', 'n_tokens_mistral': 914, 'n_tokens_neox': 863, 'n_words': 191}