<commit_before>/*
 * libdict -- generic interface definitions.
 *
 * Copyright (c) 2001-2011, <NAME>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    This product includes software developed by <NAME>.
 * 4. Neither the name <NAME> nor the names of contributors may be used to
 *    endorse or promote products derived from this software without specific
 *    prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY FAROOQ MELA ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL FAROOQ MELA BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _DICT_H_
#define _DICT_H_

#include <stddef.h>

#define DICT_VERSION_MAJOR		0
#define DICT_VERSION_MINOR		3
#define DICT_VERSION_PATCH		0

#ifndef FALSE
#define FALSE	0
#endif

#ifndef TRUE
#define TRUE	(!FALSE)
#endif

#if defined(__cplusplus) || defined(c_plusplus)
# define BEGIN_DECL	extern "C" {
# define END_DECL	}
#else
# define BEGIN_DECL
# define END_DECL
#endif

BEGIN_DECL

/* A pointer to a function that compares two keys. It needs to return a
 * negative value if k1<k2, a positive value if k1>k2, and zero if the keys are
 * equal. The comparison should be reflexive (k1>k2 implies k1<k2, etc.),
 * symmetric (k1=k1) and transitive (k1>k2 and k2>k3 -> k1>k3). */
typedef int			(*dict_compare_func)(const void *, const void *);
/* A pointer to a function that is called when a key-value pair gets removed
 * from a dictionary. */
typedef void		(*dict_delete_func)	(void *, void *);
/* A pointer to a function used for iterating over dictionary contents. */
typedef int			(*dict_visit_func)	(const void *, void *);
/* A pointer to a function that returns the hash value of a key. */
typedef unsigned	(*dict_hash_func)	(const void *);
/* A pointer to a function that returns the priority of a key/value pair. */
typedef unsigned	(*dict_prio_func)	(const void *, const void *);

/* A pointer to a function that allocates the given number of bytes. */
typedef void*		(*dict_malloc_func)	(size_t);
/* A pointer to a function that releases allocated memory. */
typedef void		(*dict_free_func)	(void *);

dict_malloc_func	dict_set_malloc(dict_malloc_func func);
dict_free_func		dict_set_free(dict_free_func func);

/* Forward declarations for transparents types dict and dict_itor. */
typedef struct dict
					dict;
typedef struct dict_itor
					dict_itor;

typedef dict_itor*	(*dict_inew_func)		(void *obj);
typedef unsigned	(*dict_dfree_func)		(void *obj);
typedef int			(*dict_insert_func)		(void *obj, void *key, void *datum,
											 int overwrite);
typedef int			(*dict_probe_func)		(void *obj, void *key,
											 void **datum);
typedef void*		(*dict_search_func)		(void *obj, const void *key);
typedef const void*	(*dict_csearch_func)	(const void *obj, const void *key);
typedef int			(*dict_remove_func)		(void *obj, const void *key);
typedef unsigned	(*dict_clear_func)		(void *obj);
typedef unsigned	(*dict_traverse_func)	(void *obj,
											 dict_visit_func visit_func);
typedef unsigned	(*dict_count_func)		(const void *obj);

typedef struct {
	dict_inew_func			inew;
	dict_dfree_func			dfree;
	dict_insert_func		insert;
	dict_probe_func			probe;
	dict_search_func		search;
	dict_csearch_func		csearch;
	dict_remove_func		remove;
	dict_clear_func			clear;
	dict_traverse_func		traverse;
	dict_count_func			count;
} dict_vtable;

typedef void		(*dict_ifree_func)		(void *itor);
typedef int			(*dict_valid_func)		(const void *itor);
typedef void		(*dict_invalidate_func)	(void *itor);
typedef int			(*dict_next_func)		(void *itor);
typedef int			(*dict_prev_func)		(void *itor);
typedef int			(*dict_nextn_func)		(void *itor, unsigned count);
typedef int			(*dict_prevn_func)		(void *itor, unsigned count);
typedef int			(*dict_first_func)		(void *itor);
typedef int			(*dict_last_func)		(void *itor);
typedef void*		(*dict_key_func)		(void *itor);
typedef void*		(*dict_data_func)		(void *itor);
typedef const void*	(*dict_cdata_func)		(const void *itor);
typedef int			(*dict_dataset_func)	(void *itor, void *datum,
											 void **old_datum);
typedef int			(*dict_iremove_func)	(void *itor);
typedef int			(*dict_icompare_func)	(void *itor1, void *itor2);

typedef struct {
	dict_ifree_func			ifree;
	dict_valid_func			valid;
	dict_invalidate_func	invalid;
	dict_next_func			next;
	dict_prev_func			prev;
	dict_nextn_func			nextn;
	dict_prevn_func			prevn;
	dict_first_func			first;
	dict_last_func			last;
	dict_key_func			key;
	dict_data_func			data;
	dict_cdata_func			cdata;
	dict_dataset_func		dataset;
	dict_iremove_func		remove;
	dict_icompare_func		compare;
} itor_vtable;<commit_msg>Replace unsigned int in size_t where value indicates a count.<commit_after>/*
 * libdict -- generic interface definitions.
 *
 * Copyright (c) 2001-2011, <NAME>
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *    This product includes software developed by <NAME>.
 * 4. Neither the name <NAME> nor the names of contributors may be used to
 *    endorse or promote products derived from this software without specific
 *    prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY <NAME> ''AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL FAROOQ MELA BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef _DICT_H_
#define _DICT_H_

#include <stddef.h>

#define DICT_VERSION_MAJOR		0
#define DICT_VERSION_MINOR		3
#define DICT_VERSION_PATCH		0

#ifndef FALSE
#define FALSE	0
#endif

#ifndef TRUE
#define TRUE	(!FALSE)
#endif

#if defined(__cplusplus) || defined(c_plusplus)
# define BEGIN_DECL	extern "C" {
# define END_DECL	}
#else
# define BEGIN_DECL
# define END_DECL
#endif

BEGIN_DECL

/* A pointer to a function that compares two keys. It needs to return a
 * negative value if k1<k2, a positive value if k1>k2, and zero if the keys are
 * equal. The comparison should be reflexive (k1>k2 implies k1<k2, etc.),
 * symmetric (k1=k1) and transitive (k1>k2 and k2>k3 -> k1>k3). */
typedef int			(*dict_compare_func)(const void *, const void *);
/* A pointer to a function that is called when a key-value pair gets removed
 * from a dictionary. */
typedef void		(*dict_delete_func)	(void *, void *);
/* A pointer to a function used for iterating over dictionary contents. */
typedef int			(*dict_visit_func)	(const void *, void *);
/* A pointer to a function that returns the hash value of a key. */
typedef unsigned	(*dict_hash_func)	(const void *);
/* A pointer to a function that returns the priority of a key/value pair. */
typedef unsigned	(*dict_prio_func)	(const void *, const void *);

/* A pointer to a function that allocates the given number of bytes. */
typedef void*		(*dict_malloc_func)	(size_t);
/* A pointer to a function that releases allocated memory. */
typedef void		(*dict_free_func)	(void *);

dict_malloc_func	dict_set_malloc(dict_malloc_func func);
dict_free_func		dict_set_free(dict_free_func func);

/* Forward declarations for transparents types dict and dict_itor. */
typedef struct dict
					dict;
typedef struct dict_itor
					dict_itor;

typedef dict_itor*	(*dict_inew_func)		(void *obj);
typedef size_t		(*dict_dfree_func)		(void *obj);
typedef int			(*dict_insert_func)		(void *obj, void *key, void *datum,
											 int overwrite);
typedef int			(*dict_probe_func)		(void *obj, void *key,
											 void **datum);
typedef void*		(*dict_search_func)		(void *obj, const void *key);
typedef const void*	(*dict_csearch_func)	(const void *obj, const void *key);
typedef int			(*dict_remove_func)		(void *obj, const void *key);
typedef size_t		(*dict_clear_func)		(void *obj);
typedef size_t		(*dict_traverse_func)	(void *obj,
											 dict_visit_func visit_func);
typedef size_t		(*dict_count_func)		(const void *obj);

typedef struct {
	dict_inew_func			inew;
	dict_dfree_func			dfree;
	dict_insert_func		insert;
	dict_probe_func			probe;
	dict_search_func		search;
	dict_csearch_func		csearch;
	dict_remove_func		remove;
	dict_clear_func			clear;
	dict_traverse_func		traverse;
	dict_count_func			count;
} dict_vtable;

typedef void		(*dict_ifree_func)		(void *itor);
typedef int			(*dict_valid_func)		(const void *itor);
typedef void		(*dict_invalidate_func)	(void *itor);
typedef int			(*dict_next_func)		(void *itor);
typedef int			(*dict_prev_func)		(void *itor);
typedef int			(*dict_nextn_func)		(void *itor, size_t count);
typedef int			(*dict_prevn_func)		(void *itor, size_t count);
typedef int			(*dict_first_func)		(void *itor);
typedef int			(*dict_last_func)		(void *itor);
typedef void*		(*dict_key_func)		(void *itor);
typedef void*		(*dict_data_func)		(void *itor);
typedef const void*	(*dict_cdata_func)		(const void *itor);
typedef int			(*dict_dataset_func)	(void *itor, void *datum,
											 void **old_datum);
typedef int			(*dict_iremove_func)	(void *itor);
typedef int			(*dict_icompare_func)	(void *itor1, void *itor2);

typedef struct {
	dict_ifree_func			ifree;
	dict_valid_func			valid;
	dict_invalidate_func	invalid;
	dict_next_func			next;
	dict_prev_func			prev;
	dict_nextn_func			nextn;
	dict_prevn_func			prevn;
	dict_first_func			first;
	dict_last_func			last;
	dict_key_func			key;
	dict_data_func			data;
	dict_cdata_func			cdata;
	dict_dataset_func		dataset;
	dict_iremove_func		remove;
	dict_icompare_func		compare;
} itor_vtable;
{'fraction_non_alphanumeric': 0.08648788479779253, 'fraction_numerical': 0.0058635854100198325, 'mean_word_length': 4.445070422535212, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 24, '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': '1014113', 'n_tokens_mistral': 4182, 'n_tokens_neox': 3744, 'n_words': 1373}