6 #ifndef TOR_SMARTLIST_H
7 #define TOR_SMARTLIST_H
45 int (*compare)(const
void **a, const
void **b));
47 int (*compare)(const
void **a, const
void **b),
49 #define smartlist_get_most_frequent(sl, compare) \
50 smartlist_get_most_frequent_((sl), (compare), NULL)
52 int (*compare)(
const void **a,
const void **b),
53 void (*free_fn)(
void *elt));
69 int (*compare)(
const void *key,
const void **member));
71 int (*compare)(
const void *key,
const void **member),
75 int (*compare)(
const void *a,
const void *b),
76 ptrdiff_t idx_field_offset,
79 int (*compare)(
const void *a,
const void *b),
80 ptrdiff_t idx_field_offset);
82 int (*compare)(
const void *a,
const void *b),
83 ptrdiff_t idx_field_offset,
86 int (*compare)(
const void *a,
const void *b),
87 ptrdiff_t idx_field_offset);
90 size_t *len_out) ATTR_MALLOC;
92 size_t join_len,
int terminate,
size_t *len_out)
140 #define SMARTLIST_FOREACH_JOIN(sl1, type1, var1, sl2, type2, var2, \
141 cmpexpr, unmatched_var2) \
143 int var1 ## _sl_idx = 0, var1 ## _sl_len=(sl1)->num_used; \
144 int var2 ## _sl_idx = 0, var2 ## _sl_len=(sl2)->num_used; \
145 int var1 ## _ ## var2 ## _cmp; \
148 for (; var2##_sl_idx < var2##_sl_len; ++var2##_sl_idx) { \
149 var2 = (sl2)->list[var2##_sl_idx]; \
150 while (var1##_sl_idx < var1##_sl_len) { \
151 var1 = (sl1)->list[var1##_sl_idx]; \
152 var1##_##var2##_cmp = (cmpexpr); \
153 if (var1##_##var2##_cmp > 0) { \
155 } else if (var1##_##var2##_cmp == 0) { \
156 goto matched_##var2; \
166 #define SMARTLIST_FOREACH_JOIN_END(var1, var2) \
void smartlist_uniq(smartlist_t *sl, int(*compare)(const void **a, const void **b), void(*free_fn)(void *a))
void smartlist_sort_digests(smartlist_t *sl)
int smartlist_ptrs_eq(const smartlist_t *s1, const smartlist_t *s2)
void smartlist_sort_digests256(smartlist_t *sl)
void smartlist_string_remove(smartlist_t *sl, const char *element)
void smartlist_intersect(smartlist_t *sl1, const smartlist_t *sl2)
void smartlist_uniq_digests(smartlist_t *sl)
void * smartlist_get_most_frequent_(const smartlist_t *sl, int(*compare)(const void **a, const void **b), int *count_out)
int smartlist_strings_eq(const smartlist_t *sl1, const smartlist_t *sl2)
const char * smartlist_get_most_frequent_string_(smartlist_t *sl, int *count_out)
void smartlist_pqueue_assert_ok(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset)
int smartlist_contains_digest(const smartlist_t *sl, const char *element)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out) ATTR_MALLOC
void smartlist_uniq_digests256(smartlist_t *sl)
void smartlist_add_vasprintf(struct smartlist_t *sl, const char *pattern, va_list args)
int smartlist_contains_string_case(const smartlist_t *sl, const char *element)
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
int smartlist_pos(const smartlist_t *sl, const void *element)
void smartlist_reverse(smartlist_t *sl)
void * smartlist_bsearch(const smartlist_t *sl, const void *key, int(*compare)(const void *key, const void **member))
int smartlist_contains_int_as_string(const smartlist_t *sl, int num)
const uint8_t * smartlist_get_most_frequent_digest256(smartlist_t *sl)
void smartlist_subtract(smartlist_t *sl1, const smartlist_t *sl2)
void smartlist_uniq_strings(smartlist_t *sl)
void smartlist_sort_strings(smartlist_t *sl)
void smartlist_pqueue_add(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset, void *item)
int smartlist_contains_string(const smartlist_t *sl, const char *element)
void * smartlist_pqueue_pop(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset)
char * smartlist_join_strings2(smartlist_t *sl, const char *join, size_t join_len, int terminate, size_t *len_out) ATTR_MALLOC
void smartlist_sort(smartlist_t *sl, int(*compare)(const void **a, const void **b))
int smartlist_string_pos(const smartlist_t *, const char *elt)
const char * smartlist_get_most_frequent_string(smartlist_t *sl)
int smartlist_ints_eq(const smartlist_t *sl1, const smartlist_t *sl2)
void smartlist_pqueue_remove(smartlist_t *sl, int(*compare)(const void *a, const void *b), ptrdiff_t idx_field_offset, void *item)
int smartlist_bsearch_idx(const smartlist_t *sl, const void *key, int(*compare)(const void *key, const void **member), int *found_out)
void smartlist_sort_pointers(smartlist_t *sl)
int smartlist_overlap(const smartlist_t *sl1, const smartlist_t *sl2)
Top-level declarations for the smartlist_t dynamic array type.
Macros for iterating over the elements of a smartlist_t.
Header for smartlist_split.c.