<commit_before>//
//  trie.h
//

#ifndef trie_h
#define trie_h

template<typename T>
struct trie_node
{
    T value;
    trie_node *chars[256];
    
    trie_node() : value(), chars() {}
    
    ~trie_node()
    {
        for (int i = 0; i < 256; i++) {
            if (chars[i]) {
                delete chars[i];
            }
        }
    }
};

template<typename T>
struct trie
{
    typedef std::pair<std::string,uint32_t> trie_entry;
    
    trie_node<trie_entry> *root_node;
    
    trie()
    {
        root_node = new trie_node<trie_entry>();
    }
    
    ~trie()
    {
        delete root_node;
    }
    
    void insert(trie_node<trie_entry> *t, trie_entry value)
    {
        int c;
        const char *p = value.first.c_str();
        while ((c = *p++)) {
            if (t->chars[c] == nullptr) {
                t->chars[c] = new trie_node<trie_entry>();
            }
            t = t->chars[c];
        }
        t->value = value;
    }<commit_msg>Fix typo in trie typedef<commit_after>//
//  trie.h
//

#ifndef trie_h
#define trie_h

template<typename T>
struct trie_node
{
    T value;
    trie_node *chars[256];
    
    trie_node() : value(), chars() {}
    
    ~trie_node()
    {
        for (int i = 0; i < 256; i++) {
            if (chars[i]) {
                delete chars[i];
            }
        }
    }
};

template<typename T>
struct trie
{
    typedef std::pair<std::string,T> trie_entry;
    
    trie_node<trie_entry> *root_node;
    
    trie()
    {
        root_node = new trie_node<trie_entry>();
    }
    
    ~trie()
    {
        delete root_node;
    }
    
    void insert(trie_node<trie_entry> *t, trie_entry value)
    {
        int c;
        const char *p = value.first.c_str();
        while ((c = *p++)) {
            if (t->chars[c] == nullptr) {
                t->chars[c] = new trie_node<trie_entry>();
            }
            t = t->chars[c];
        }
        t->value = value;
    }
{'fraction_non_alphanumeric': 0.14666666666666667, 'fraction_numerical': 0.008205128205128205, 'mean_word_length': 1.5570117955439056, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 25, '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': '2787216', 'n_tokens_mistral': 745, 'n_tokens_neox': 722, 'n_words': 142}