<commit_before>/* $Id$ */

#include "n_hash_int.h"
#include "narray.h"
#include "nmalloc.h"

tn_array *n_hash_keys_ext(const tn_hash *ht, int cp)
{
    register size_t i;
    register struct hash_bucket *tmp;
    tn_array *keys; 
    tn_fn_free fn = NULL;
    
    if (cp)
        fn = free;

    keys = n_array_new(ht->items, fn, (tn_fn_cmp)strcmp);
    
    for (i = 0; i < ht->size; i++) {
        if (ht->table[i] == NULL)
            continue;
        
        for (tmp = ht->table[i]; tmp != NULL; tmp = tmp->next)
            n_array_push(keys, cp ? n_strdup(tmp->key) : tmp->key); 
   }
    
    return keys;
}

#undef n_hash_keys
tn_array *n_hash_keys(const tn_hash *ht) 
{
    return n_hash_keys_ext(ht, 0);
}

tn_array *n_hash_values_ext(const tn_hash *ht, tn_fn_dup dupfn)
{
    register size_t i;
    register struct hash_bucket *tmp;
    tn_array *values; 

    values = n_array_new(ht->items, NULL, NULL);
    
    for (i = 0; i < ht->size; i++) {
        if (ht->table[i] == NULL)
            continue;
        
        for (tmp = ht->table[i]; tmp != NULL; tmp = tmp->next)
            n_array_push(values, dupfn ? dupfn(tmp->data) : tmp->data); 
   }
    
    return values;
}<commit_msg>- fix<commit_after>/* $Id$ */

#include "n_hash_int.h"
#include "narray.h"
#include "nmalloc.h"

tn_array *n_hash_keys_ext(const tn_hash *ht, int cp)
{
    register size_t i;
    register struct hash_bucket *tmp;
    tn_array *keys; 
    tn_fn_free fn = NULL;
    
    if (cp)
        fn = free;

    keys = n_array_new(ht->items, fn, (tn_fn_cmp)strcmp);
    
    for (i = 0; i < ht->size; i++) {
        if (ht->table[i] == NULL)
            continue;
        
        for (tmp = ht->table[i]; tmp != NULL; tmp = tmp->next)
            n_array_push(keys, cp ? n_strdup(tmp->key) : tmp->key); 
   }
    
    return keys;
}

#undef n_hash_keys
tn_array *n_hash_keys(const tn_hash *ht) 
{
    return n_hash_keys_ext(ht, 0);
}

tn_array *n_hash_values(const tn_hash *ht)
{
    register size_t i;
    register struct hash_bucket *tmp;
    tn_array *values; 

    values = n_array_new(ht->items, NULL, NULL);
    
    for (i = 0; i < ht->size; i++) {
        if (ht->table[i] == NULL)
            continue;
        
        for (tmp = ht->table[i]; tmp != NULL; tmp = tmp->next)
            n_array_push(values, tmp->data); 
    }
    
    return values;
}
{'fraction_non_alphanumeric': 0.14679677556215528, 'fraction_numerical': 0.002545608824777259, 'mean_word_length': 2.2434662998624484, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 30, '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': '4388323', 'n_tokens_mistral': 946, 'n_tokens_neox': 921, 'n_words': 213}