t8  UNKNOWN
t8code is a C library to manage a forest of adaptive space-trees of general element classes in parallel.
t8_containers.h
Go to the documentation of this file.
1 /*
2  This file is part of t8code.
3  t8code is a C library to manage a collection (a forest) of multiple
4  connected adaptive space-trees of general element classes in parallel.
5 
6  Copyright (C) 2015 the developers
7 
8  t8code is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation; either version 2 of the License, or
11  (at your option) any later version.
12 
13  t8code 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
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with t8code; if not, write to the Free Software Foundation, Inc.,
20  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22 
28 #ifndef T8_CONTAINERS_H
29 #define T8_CONTAINERS_H
30 
31 #include <t8.h>
32 #include <t8_element.h>
33 
41 typedef struct
42 {
44  sc_array_t array;
46 
47 T8_EXTERN_C_BEGIN ();
48 
55 
65 t8_element_array_new_count (t8_eclass_scheme_c *scheme, size_t num_elements);
66 
71 void
73 
80 void
81 t8_element_array_init_size (t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements);
82 
93 void
94 t8_element_array_init_view (t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length);
95 
107 void
109  size_t elem_count);
110 
121 void
123  size_t num_elements);
124 
132 void
133 t8_element_array_resize (t8_element_array_t *element_array, size_t new_count);
134 
140 void
142 
148 t8_element_t *
150 
157 t8_element_t *
158 t8_element_array_push_count (t8_element_array_t *element_array, size_t count);
159 
166 t8_element_t *
168 
175 t8_element_t *
176 t8_element_array_index_int (t8_element_array_t *element_array, int index);
177 
184 
189 size_t
190 t8_element_array_get_count (const t8_element_array_t *element_array);
195 size_t
197 
203 t8_element_t *
205 
210 sc_array_t *
212 
218 void
220 
227 void
229 
230 T8_EXTERN_C_END ();
231 
232 #endif /* !T8_CONTAINERS_HXX */
This struct holds virtual functions for a particular element class.
Definition: t8_element_cxx.hxx:41
The t8_element_array_t is an array to store t8_element_t * of a given eclass_scheme implementation.
Definition: t8_containers.h:42
sc_array_t array
The array in which the elements are stored.
Definition: t8_containers.h:44
t8_eclass_scheme_c * scheme
An eclass scheme of which elements should be stored.
Definition: t8_containers.h:43
This is the administrative header file for t8code.
int32_t t8_locidx_t
A type for processor-local indexing.
Definition: t8.h:89
t8_element_array_t * t8_element_array_new_count(t8_eclass_scheme_c *scheme, size_t num_elements)
Creates a new array structure with a given length (number of elements) and calls t8_element_new for t...
Definition: t8_containers.cxx:70
void t8_element_array_init(t8_element_array_t *element_array, t8_eclass_scheme_c *scheme)
Initializes an already allocated (or static) array structure.
Definition: t8_containers.cxx:84
void t8_element_array_reset(t8_element_array_t *element_array)
Sets the array count to zero and frees all elements.
Definition: t8_containers.cxx:289
void t8_element_array_init_copy(t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, t8_element_t *data, size_t num_elements)
Initializes an already allocated (or static) array structure and copy an existing array of t8_element...
Definition: t8_containers.cxx:139
t8_element_array_t * t8_element_array_new(t8_eclass_scheme_c *scheme)
Creates a new array structure with 0 elements.
Definition: t8_containers.cxx:56
t8_element_t * t8_element_array_push(t8_element_array_t *element_array)
Enlarge an array by one element.
Definition: t8_containers.cxx:211
t8_element_t * t8_element_array_index_locidx(t8_element_array_t *element_array, t8_locidx_t index)
Return a given element in an array.
Definition: t8_containers.cxx:233
void t8_element_array_init_view(t8_element_array_t *view, t8_element_array_t *array, size_t offset, size_t length)
Initializes an already allocated (or static) view from existing t8_element_array.
Definition: t8_containers.cxx:117
t8_element_t * t8_element_array_get_data(t8_element_array_t *element_array)
Return a pointer to the real data array stored in a t8_element_array.
Definition: t8_containers.cxx:268
size_t t8_element_array_get_size(t8_element_array_t *element_array)
Return the data size of elements stored in a t8_element_array_t.
Definition: t8_containers.cxx:261
sc_array_t * t8_element_array_get_array(t8_element_array_t *element_array)
Return a pointer to the sc_array stored in a t8_element_array.
Definition: t8_containers.cxx:281
void t8_element_array_resize(t8_element_array_t *element_array, size_t new_count)
Change the number of elements stored in an element array.
Definition: t8_containers.cxx:171
t8_eclass_scheme_c * t8_element_array_get_scheme(t8_element_array_t *element_array)
Return the eclass scheme associated to a t8_element_array.
Definition: t8_containers.cxx:247
void t8_element_array_copy(t8_element_array_t *dest, t8_element_array_t *src)
Copy the contents of an array into another.
Definition: t8_containers.cxx:202
void t8_element_array_truncate(t8_element_array_t *element_array)
Sets the array count to zero, but does not free elements.
Definition: t8_containers.cxx:299
void t8_element_array_init_size(t8_element_array_t *element_array, t8_eclass_scheme_c *scheme, size_t num_elements)
Initializes an already allocated (or static) array structure and allocates a given number of elements...
Definition: t8_containers.cxx:99
t8_element_t * t8_element_array_push_count(t8_element_array_t *element_array, size_t count)
Enlarge an array by a number of elements.
Definition: t8_containers.cxx:221
void t8_element_array_init_data(t8_element_array_t *view, t8_element_t *base, t8_eclass_scheme_c *scheme, size_t elem_count)
Initializes an already allocated (or static) view from given plain C data (array of t8_element_t).
Definition: t8_containers.cxx:129
size_t t8_element_array_get_count(const t8_element_array_t *element_array)
Return the number of elements stored in a t8_element_array_t.
Definition: t8_containers.cxx:254
t8_element_t * t8_element_array_index_int(t8_element_array_t *element_array, int index)
Return a given element in an array.
Definition: t8_containers.cxx:240
This file defines basic operations on an element in a refinement tree.
struct t8_element t8_element_t
Opaque structure for a generic element, only used as pointer.
Definition: t8_element.h:42