libsc 2.8.5.210-64a7
The SC library provides support for parallel scientific applications.
sc_containers.h
Go to the documentation of this file.
1/*
2 This file is part of the SC Library.
3 The SC Library provides support for parallel scientific applications.
4
5 Copyright (C) 2010 The University of Texas System
6 Additional copyright (C) 2011 individual authors
7
8 The SC Library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 The SC Library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with the SC Library; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22*/
23
24#ifndef SC_CONTAINERS_H
25#define SC_CONTAINERS_H
26
39#include <sc.h>
40
41SC_EXTERN_C_BEGIN;
42
43/* Hash macros from lookup3.c by Bob Jenkins, May 2006, public domain. */
44#define sc_hash_rot(x,k) (((x) << (k)) | ((x) >> (32 - (k))))
45#define sc_hash_mix(a,b,c) ((void) \
46 (a -= c, a ^= sc_hash_rot(c, 4), c += b, \
47 b -= a, b ^= sc_hash_rot(a, 6), a += c, \
48 c -= b, c ^= sc_hash_rot(b, 8), b += a, \
49 a -= c, a ^= sc_hash_rot(c,16), c += b, \
50 b -= a, b ^= sc_hash_rot(a,19), a += c, \
51 c -= b, c ^= sc_hash_rot(b, 4), b += a))
52#define sc_hash_final(a,b,c) ((void) \
53 (c ^= b, c -= sc_hash_rot(b,14), \
54 a ^= c, a -= sc_hash_rot(c,11), \
55 b ^= a, b -= sc_hash_rot(a,25), \
56 c ^= b, c -= sc_hash_rot(b,16), \
57 a ^= c, a -= sc_hash_rot(c, 4), \
58 b ^= a, b -= sc_hash_rot(a,14), \
59 c ^= b, c -= sc_hash_rot(b,24)))
60
66typedef unsigned int (*sc_hash_function_t) (const void *v, const void *u);
67
72typedef int (*sc_equal_function_t) (const void *v1,
73 const void *v2, const void *u);
74
80typedef int (*sc_hash_foreach_t) (void **v, const void *u);
81
90typedef struct sc_array
91{
92 /* interface variables */
93 size_t elem_size;
94 size_t elem_count;
96 /* implementation variables */
97 ssize_t byte_alloc;
102 char *array;
103}
105
107#define SC_ARRAY_IS_OWNER(a) ((a)->byte_alloc >= 0)
109#define SC_ARRAY_BYTE_ALLOC(a) ((size_t) \
110 (SC_ARRAY_IS_OWNER (a) ? (a)->byte_alloc : -((a)->byte_alloc + 1)))
111
118size_t sc_array_memory_used (sc_array_t * array, int is_dynamic);
119
124sc_array_t *sc_array_new (size_t elem_size);
125
132sc_array_t *sc_array_new_count (size_t elem_size, size_t elem_count);
133
135#define sc_array_new_size(s,c) (sc_array_new_count ((s), (c)))
136
145 size_t offset, size_t length);
146
154 size_t elem_size, size_t elem_count);
155
160
166
171void sc_array_init (sc_array_t * array, size_t elem_size);
172
181 size_t elem_size, size_t elem_count);
182
191 size_t elem_size, size_t elem_count);
192
204 size_t offset, size_t length);
205
219 sc_array_t * array,
220 size_t elem_size,
221 size_t elem_count);
222
232void sc_array_init_data (sc_array_t * view, void *base,
233 size_t elem_size, size_t elem_count);
234
241void sc_array_memset (sc_array_t * array, int c);
242
253
262
272void sc_array_rewind (sc_array_t * array, size_t new_count);
273
284void sc_array_resize (sc_array_t * array, size_t new_count);
285
294
305void sc_array_copy_into (sc_array_t * dest, size_t dest_offset,
306 sc_array_t * src);
307
322void sc_array_move_part (sc_array_t * dest, size_t dest_offset,
323 sc_array_t * src, size_t src_offset,
324 size_t count);
325
331 int (*compar) (const void *,
332 const void *));
333
340 int (*compar) (const void *,
341 const void *));
342
350 sc_array_t * other);
351
358 int (*compar) (const void *,
359 const void *));
360
368 const void *key,
369 int (*compar) (const void *,
370 const void *));
371
377typedef size_t (*sc_array_type_t) (sc_array_t * array,
378 size_t index, void *data);
379
396void sc_array_split (sc_array_t * array, sc_array_t * offsets,
397 size_t num_types, sc_array_type_t type_fn,
398 void *data);
399
408
421 sc_array_t * newindices, int keepperm);
422
426unsigned int sc_array_checksum (sc_array_t * array);
427
442 void *temp,
443 int (*compar) (const void *,
444 const void *));
445
456 void *result,
457 int (*compar) (const void *,
458 const void *));
459
465/*@unused@*/
466static inline void *
467sc_array_index (sc_array_t * array, size_t iz)
468{
469 SC_ASSERT (iz < array->elem_count);
470
471 return (void *) (array->array + array->elem_size * iz);
472}
473
480/*@unused@*/
481static inline void *
482sc_array_index_null (sc_array_t * array, size_t iz)
483{
484 SC_ASSERT (iz <= array->elem_count);
485
486 return iz == array->elem_count ? NULL :
487 (void *) (array->array + array->elem_size * iz);
488}
489
493/*@unused@*/
494static inline void *
495sc_array_index_int (sc_array_t * array, int i)
496{
497 SC_ASSERT (i >= 0 && (size_t) i < array->elem_count);
498
499 return (void *) (array->array + (array->elem_size * (size_t) i));
500}
501
505/*@unused@*/
506static inline void *
507sc_array_index_long (sc_array_t * array, long l)
508{
509 SC_ASSERT (l >= 0 && (size_t) l < array->elem_count);
510
511 return (void *) (array->array + (array->elem_size * (size_t) l));
512}
513
517/*@unused@*/
518static inline void *
519sc_array_index_ssize_t (sc_array_t * array, ssize_t is)
520{
521 SC_ASSERT (is >= 0 && (size_t) is < array->elem_count);
522
523 return (void *) (array->array + (array->elem_size * (size_t) is));
524}
525
529/*@unused@*/
530static inline void *
531sc_array_index_int16 (sc_array_t * array, int16_t i16)
532{
533 SC_ASSERT (i16 >= 0 && (size_t) i16 < array->elem_count);
534
535 return (void *) (array->array + (array->elem_size * (size_t) i16));
536}
537
541/*@unused@*/
542static inline size_t
543sc_array_position (sc_array_t * array, void *element)
544{
545 ptrdiff_t position;
546
547 SC_ASSERT (array->array <= (char *) element);
548 SC_ASSERT (((char *) element - array->array) %
549 (ptrdiff_t) array->elem_size == 0);
550
551 position = ((char *) element - array->array) / (ptrdiff_t) array->elem_size;
552 SC_ASSERT (0 <= position && position < (ptrdiff_t) array->elem_count);
553
554 return (size_t) position;
555}
556
562/*@unused@*/
563static inline void *
564sc_array_pop (sc_array_t * array)
565{
566 SC_ASSERT (SC_ARRAY_IS_OWNER (array));
567 SC_ASSERT (array->elem_count > 0);
568
569 return (void *) (array->array + (array->elem_size * --array->elem_count));
570}
571
576/*@unused@*/
577static inline void *
578sc_array_push_count (sc_array_t * array, size_t add_count)
579{
580 const size_t old_count = array->elem_count;
581 const size_t new_count = old_count + add_count;
582
583 SC_ASSERT (SC_ARRAY_IS_OWNER (array));
584
585 if (array->elem_size * new_count > (size_t) array->byte_alloc) {
586 sc_array_resize (array, new_count);
587 }
588 else {
589 array->elem_count = new_count;
590 }
591
592 return (void *) (array->array + array->elem_size * old_count);
593}
594
599/*@unused@*/
600static inline void *
601sc_array_push (sc_array_t * array)
602{
603 return sc_array_push_count (array, 1);
604}
605
612typedef struct sc_mstamp
613{
614 size_t elem_size;
615 size_t per_stamp;
616 size_t stamp_size;
617 size_t cur_snext;
618 char *current;
620}
622
641 size_t stamp_unit, size_t elem_size);
642
648
659
669
675
685typedef struct sc_mempool
686{
687 /* interface variables */
688 size_t elem_size;
689 size_t elem_count;
692 /* implementation variables */
695}
697
703
709sc_mempool_t *sc_mempool_new (size_t elem_size);
710
718
721 size_t elem_size);
722
728
735
738
742
747/*@unused@*/
748static inline void *
749sc_mempool_alloc (sc_mempool_t * mempool)
750{
751 void *ret;
752 sc_array_t *freed = &mempool->freed;
753
754 ++mempool->elem_count;
755
756 if (freed->elem_count > 0) {
757 ret = *(void **) sc_array_pop (freed);
758 }
759 else {
760 ret = sc_mstamp_alloc (&mempool->mstamp);
761 if (mempool->zero_and_persist) {
762 memset (ret, 0, mempool->elem_size);
763 }
764 }
765
766#ifdef SC_ENABLE_DEBUG
767 if (!mempool->zero_and_persist) {
768 memset (ret, -1, mempool->elem_size);
769 }
770#endif
771
772 return ret;
773}
774
778/*@unused@*/
779static inline void
780sc_mempool_free (sc_mempool_t * mempool, void *elem)
781{
782 sc_array_t *freed = &mempool->freed;
783
784 SC_ASSERT (mempool->elem_count > 0);
785
786#ifdef SC_ENABLE_DEBUG
787 if (!mempool->zero_and_persist) {
788 memset (elem, -1, mempool->elem_size);
789 }
790#endif
791
792 --mempool->elem_count;
793
794 *(void **) sc_array_push (freed) = elem;
795}
796
799typedef struct sc_link
800{
801 void *data;
802 struct sc_link *next;
803}
805
808typedef struct sc_list
809{
810 /* interface variables */
811 size_t elem_count;
812 sc_link_t *first;
813 sc_link_t *last;
814
815 /* implementation variables */
816 int allocator_owned;
817 sc_mempool_t *allocator; /* must allocate sc_link_t */
818}
820
827size_t sc_list_memory_used (sc_list_t * list, int is_dynamic);
828
835
841
847void sc_list_init (sc_list_t * list, sc_mempool_t * allocator);
848
855
861
867sc_link_t *sc_list_prepend (sc_list_t * list, void *data);
868
874sc_link_t *sc_list_append (sc_list_t * list, void *data);
875
883 sc_link_t * pred, void *data);
884
892void *sc_list_remove (sc_list_t * list, sc_link_t * pred);
893
898void *sc_list_pop (sc_list_t * list);
899
903typedef struct sc_hash
904{
905 /* interface variables */
906 size_t elem_count;
908 /* implementation variables */
910 void *user_data;
911 sc_hash_function_t hash_fn;
912 sc_equal_function_t equal_fn;
913 size_t resize_checks, resize_actions;
914 int allocator_owned;
916}
918
925unsigned int sc_hash_function_string (const void *s, const void *u);
926
932
941 sc_equal_function_t equal_fn,
942 void *user_data, sc_mempool_t * allocator);
943
950
957
964
972
978
986int sc_hash_lookup (sc_hash_t * hash, void *v, void ***found);
987
995int sc_hash_insert_unique (sc_hash_t * hash, void *v,
996 void ***found);
997
1004int sc_hash_remove (sc_hash_t * hash, void *v, void **found);
1005
1010
1013void sc_hash_print_statistics (int package_id,
1014 int log_priority,
1015 sc_hash_t * hash);
1016
1018{
1019 sc_array_t *pa;
1020 sc_hash_function_t hash_fn;
1021 sc_equal_function_t equal_fn;
1022 void *user_data;
1023 void *current_item;
1024}
1026
1030typedef struct sc_hash_array
1031{
1032 /* implementation variables */
1033 sc_array_t a;
1034 sc_hash_array_data_t internal_data;
1035 sc_hash_t *h;
1036}
1038
1044
1051 sc_hash_function_t hash_fn,
1052 sc_equal_function_t equal_fn,
1053 void *user_data);
1054
1058
1062
1067
1077 void *v, size_t *position);
1078
1091 void *v, size_t *position);
1092
1100 sc_array_t * rip);
1101
1107typedef struct sc_recycle_array
1108{
1109 /* interface variables */
1110 size_t elem_count; /* number of valid entries */
1111
1112 /* implementation variables */
1113 sc_array_t a;
1114 sc_array_t f;
1115}
1117
1123 size_t elem_size);
1124
1131
1140 size_t *position);
1141
1150 size_t position);
1151
1152SC_EXTERN_C_END;
1153
1154#endif /* !SC_CONTAINERS_H */
Support for process management (memory allocation, logging, etc.)
void sc_array_permute(sc_array_t *array, sc_array_t *newindices, int keepperm)
Given permutation newindices, permute array in place.
unsigned int(* sc_hash_function_t)(const void *v, const void *u)
Function to compute a hash value of an object.
Definition: sc_containers.h:66
sc_hash_array_t * sc_hash_array_new(size_t elem_size, sc_hash_function_t hash_fn, sc_equal_function_t equal_fn, void *user_data)
Create a new hash array.
sc_hash_t * sc_hash_new(sc_hash_function_t hash_fn, sc_equal_function_t equal_fn, void *user_data, sc_mempool_t *allocator)
Create a new hash table.
struct sc_list sc_list_t
The sc_list object provides a linked list.
sc_array_t * sc_array_new_view(sc_array_t *array, size_t offset, size_t length)
Creates a new view of an existing sc_array_t.
sc_link_t * sc_list_insert(sc_list_t *list, sc_link_t *pred, void *data)
Insert an element after a given list position.
struct sc_recycle_array sc_recycle_array_t
The sc_recycle_array object provides an array of slots that can be reused.
int sc_hash_array_lookup(sc_hash_array_t *hash_array, void *v, size_t *position)
Check if an object is contained in a hash array.
void sc_mempool_reset(sc_mempool_t *mempool)
Same as sc_mempool_destroy, but does not free the pointer.
void sc_array_init_reshape(sc_array_t *view, sc_array_t *array, size_t elem_size, size_t elem_count)
Initialize an already allocated (or static) view from existing sc_array_t.
void sc_list_init(sc_list_t *list, sc_mempool_t *allocator)
Initialize a list object with an external link allocator.
void sc_array_init(sc_array_t *array, size_t elem_size)
Initializes an already allocated (or static) array structure.
size_t sc_hash_array_memory_used(sc_hash_array_t *ha)
Calculate the memory used by a hash array.
sc_array_t * sc_array_new_data(void *base, size_t elem_size, size_t elem_count)
Creates a new view of an existing plain C array.
void sc_recycle_array_reset(sc_recycle_array_t *rec_array)
Reset a recycle array.
sc_mempool_t * sc_mempool_new(size_t elem_size)
Creates a new mempool structure with the zero_and_persist option off.
void sc_array_rewind(sc_array_t *array, size_t new_count)
Shorten an array without reallocating it.
void sc_array_init_data(sc_array_t *view, void *base, size_t elem_size, size_t elem_count)
Initializes an already allocated (or static) view from given plain C data.
int sc_hash_remove(sc_hash_t *hash, void *v, void **found)
Remove an object from a hash table.
void sc_array_init_size(sc_array_t *array, size_t elem_size, size_t elem_count)
Initializes an already allocated (or static) array structure and allocates a given number of elements...
int(* sc_hash_foreach_t)(void **v, const void *u)
Function to call on every data item of a hash table.
Definition: sc_containers.h:80
void sc_array_copy(sc_array_t *dest, sc_array_t *src)
Copy the contents of one array into another.
void * sc_list_pop(sc_list_t *list)
Remove an element from the front of the list.
void sc_mstamp_reset(sc_mstamp_t *mst)
Free all memory in a stamp structure and all items previously returned.
size_t sc_mstamp_memory_used(sc_mstamp_t *mst)
Return memory size in bytes of all data allocated in the container.
sc_mempool_t * sc_mempool_new_zero_and_persist(size_t elem_size)
Creates a new mempool structure with the zero_and_persist option on.
void sc_hash_destroy(sc_hash_t *hash)
Destroy a hash table.
sc_array_t * sc_array_new_count(size_t elem_size, size_t elem_count)
Creates a new array structure with a given length (number of elements).
void sc_mempool_destroy(sc_mempool_t *mempool)
Destroy a mempool structure.
int sc_hash_insert_unique(sc_hash_t *hash, void *v, void ***found)
Insert an object into a hash table if it is not contained already.
void sc_array_split(sc_array_t *array, sc_array_t *offsets, size_t num_types, sc_array_type_t type_fn, void *data)
Compute the offsets of groups of enumerable types in an array.
void sc_hash_destroy_null(sc_hash_t **phash)
Destroy a hash table and set its pointer to NULL.
void sc_array_resize(sc_array_t *array, size_t new_count)
Sets the element count to new_count.
void sc_list_unlink(sc_list_t *list)
Unlink all list elements without returning them to the mempool.
unsigned int sc_hash_function_string(const void *s, const void *u)
Compute a hash value from a null-terminated string.
void * sc_recycle_array_insert(sc_recycle_array_t *rec_array, size_t *position)
Insert an object into the recycle array.
void sc_hash_truncate(sc_hash_t *hash)
Remove all entries from a hash table in O(N).
size_t sc_hash_memory_used(sc_hash_t *hash)
Calculate the memory used by a hash table.
struct sc_array sc_array_t
The sc_array object provides a dynamic array of equal-size elements.
struct sc_hash_array sc_hash_array_t
The sc_hash_array implements an array backed up by a hash table.
void sc_array_destroy_null(sc_array_t **parray)
Destroys an array structure and sets the pointer to NULL.
void sc_array_reset(sc_array_t *array)
Sets the array count to zero and frees all elements.
size_t sc_mempool_memory_used(sc_mempool_t *mempool)
Calculate the memory used by a memory pool.
void * sc_recycle_array_remove(sc_recycle_array_t *rec_array, size_t position)
Remove an object from the recycle array.
void * sc_mstamp_alloc(sc_mstamp_t *mst)
Return a new item.
void sc_array_sort(sc_array_t *array, int(*compar)(const void *, const void *))
Sorts the array in ascending order wrt.
size_t(* sc_array_type_t)(sc_array_t *array, size_t index, void *data)
Function to determine the enumerable type of an object in an array.
Definition: sc_containers.h:377
struct sc_hash sc_hash_t
The sc_hash implements a hash table.
void sc_array_uniq(sc_array_t *array, int(*compar)(const void *, const void *))
Removed duplicate entries from a sorted array.
void sc_mempool_destroy_null(sc_mempool_t **pmempool)
Destroy a mempool structure.
void sc_hash_array_truncate(sc_hash_array_t *hash_array)
Remove all elements from the hash array.
struct sc_link sc_link_t
The sc_link structure is one link of a linked list.
sc_list_t * sc_list_new(sc_mempool_t *allocator)
Allocate a new, empty linked list.
void sc_array_destroy(sc_array_t *array)
Destroys an array structure.
void sc_recycle_array_init(sc_recycle_array_t *rec_array, size_t elem_size)
Initialize a recycle array.
size_t sc_array_memory_used(sc_array_t *array, int is_dynamic)
Calculate the memory used by an array.
struct sc_mempool sc_mempool_t
The sc_mempool object provides a large pool of equal-size elements.
void sc_mstamp_truncate(sc_mstamp_t *mst)
Free all memory in a stamp structure and initialize it anew.
ssize_t sc_array_bsearch(sc_array_t *array, const void *key, int(*compar)(const void *, const void *))
Performs a binary search on an array.
void sc_array_init_view(sc_array_t *view, sc_array_t *array, size_t offset, size_t length)
Initializes an already allocated (or static) view from existing sc_array_t.
void sc_mempool_init(sc_mempool_t *mempool, size_t elem_size)
Same as sc_mempool_new, but for an already allocated sc_mempool_t pointer.
void sc_array_memset(sc_array_t *array, int c)
Run memset on the array storage.
size_t sc_array_pqueue_add(sc_array_t *array, void *temp, int(*compar)(const void *, const void *))
Adds an element to a priority queue.
void sc_hash_array_rip(sc_hash_array_t *hash_array, sc_array_t *rip)
Extract the array data from a hash array and destroy everything else.
void sc_array_init_count(sc_array_t *array, size_t elem_size, size_t elem_count)
Initializes an already allocated (or static) array structure and allocates a given number of elements...
void sc_hash_unlink(sc_hash_t *hash)
Unlink all hash elements without returning them to the mempool.
sc_array_t * sc_array_new(size_t elem_size)
Creates a new array structure with 0 elements.
void sc_mempool_truncate(sc_mempool_t *mempool)
Invalidates all previously returned pointers, resets count to 0.
void sc_hash_unlink_destroy(sc_hash_t *hash)
Same effect as unlink and destroy, but in O(1).
void sc_list_reset(sc_list_t *list)
Remove all elements from a list in O(N).
int sc_array_is_sorted(sc_array_t *array, int(*compar)(const void *, const void *))
Check whether the array is sorted wrt.
struct sc_mstamp sc_mstamp_t
A data container to create memory items of the same size.
void sc_list_destroy(sc_list_t *list)
Destroy a linked list structure in O(N).
int sc_array_is_permutation(sc_array_t *array)
Determine whether array is an array of size_t's whose entries include every integer 0 <= i < array->e...
size_t sc_list_memory_used(sc_list_t *list, int is_dynamic)
Calculate the total memory used by a list.
void sc_hash_array_destroy(sc_hash_array_t *hash_array)
Destroy a hash array.
int sc_hash_array_is_valid(sc_hash_array_t *hash_array)
Check the internal consistency of a hash array.
int sc_hash_lookup(sc_hash_t *hash, void *v, void ***found)
Check if an object is contained in the hash table.
sc_link_t * sc_list_prepend(sc_list_t *list, void *data)
Insert a list element at the beginning of the list.
void sc_array_copy_into(sc_array_t *dest, size_t dest_offset, sc_array_t *src)
Copy the contents of one array into some portion of another.
void sc_mstamp_init(sc_mstamp_t *mst, size_t stamp_unit, size_t elem_size)
Initialize a memory stamp container.
void sc_hash_foreach(sc_hash_t *hash, sc_hash_foreach_t fn)
Invoke a callback for every member of the hash table.
void sc_array_truncate(sc_array_t *array)
Sets the array count to zero, but does not free elements.
sc_link_t * sc_list_append(sc_list_t *list, void *data)
Insert a list element at the end of the list.
#define SC_ARRAY_IS_OWNER(a)
test whether the sc_array_t owns its array
Definition: sc_containers.h:107
void * sc_list_remove(sc_list_t *list, sc_link_t *pred)
Remove an element after a given list position.
int sc_array_is_equal(sc_array_t *array, sc_array_t *other)
Check whether two arrays have equal size, count, and content.
void sc_hash_print_statistics(int package_id, int log_priority, sc_hash_t *hash)
Compute and print statistical information about the occupancy.
void sc_array_move_part(sc_array_t *dest, size_t dest_offset, sc_array_t *src, size_t src_offset, size_t count)
Copy part of one array into another using memmove (3).
void * sc_hash_array_insert_unique(sc_hash_array_t *hash_array, void *v, size_t *position)
Insert an object into a hash array if it is not contained already.
size_t sc_array_pqueue_pop(sc_array_t *array, void *result, int(*compar)(const void *, const void *))
Pops the smallest element from a priority queue.
int(* sc_equal_function_t)(const void *v1, const void *v2, const void *u)
Function to check equality of two objects.
Definition: sc_containers.h:72
unsigned int sc_array_checksum(sc_array_t *array)
Computes the adler32 checksum of array data (see zlib documentation).
The sc_array object provides a dynamic array of equal-size elements.
Definition: sc_containers.h:91
size_t elem_count
number of valid elements
Definition: sc_containers.h:94
size_t elem_size
size of a single element
Definition: sc_containers.h:93
char * array
linear array to store elements
Definition: sc_containers.h:102
ssize_t byte_alloc
number of allocated bytes or -(number of viewed bytes + 1) if this is a view: the "+ 1" distinguishes...
Definition: sc_containers.h:97
Definition: sc_containers.h:1018
The sc_hash_array implements an array backed up by a hash table.
Definition: sc_containers.h:1031
The sc_hash implements a hash table.
Definition: sc_containers.h:904
size_t elem_count
total number of objects contained
Definition: sc_containers.h:906
sc_mempool_t * allocator
must allocate sc_link_t
Definition: sc_containers.h:915
sc_array_t * slots
the slot count is slots->elem_count
Definition: sc_containers.h:909
void * user_data
user data passed to hash function
Definition: sc_containers.h:910
The sc_list object provides a linked list.
Definition: sc_containers.h:809
The sc_mempool object provides a large pool of equal-size elements.
Definition: sc_containers.h:686
sc_array_t freed
buffers the freed elements
Definition: sc_containers.h:694
sc_mstamp_t mstamp
fixed-size chunk allocator
Definition: sc_containers.h:693
size_t elem_count
number of valid elements
Definition: sc_containers.h:689
size_t elem_size
size of a single element
Definition: sc_containers.h:688
int zero_and_persist
Boolean; is set in constructor.
Definition: sc_containers.h:690
A data container to create memory items of the same size.
Definition: sc_containers.h:613
size_t cur_snext
Next number within a stamp.
Definition: sc_containers.h:617
size_t stamp_size
Bytes allocated in a stamp.
Definition: sc_containers.h:616
sc_array_t remember
Collects all stamps.
Definition: sc_containers.h:619
size_t per_stamp
Number of items per stamp.
Definition: sc_containers.h:615
char * current
Memory of current stamp.
Definition: sc_containers.h:618
size_t elem_size
Input parameter: size per item.
Definition: sc_containers.h:614
The sc_recycle_array object provides an array of slots that can be reused.
Definition: sc_containers.h:1108