t8  1.2.0
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 
54 
64  size_t num_elements);
65 
70 void t8_element_array_init (t8_element_array_t *element_array,
71  t8_eclass_scheme_c *scheme);
72 
80  *element_array,
81  t8_eclass_scheme_c *scheme,
82  size_t num_elements);
83 
95  t8_element_array_t *array,
96  size_t offset, size_t length);
97 
110  t8_element_t *base,
111  t8_eclass_scheme_c *scheme,
112  size_t elem_count);
113 
125  *element_array,
126  t8_eclass_scheme_c *scheme,
127  t8_element_t *data,
128  size_t num_elements);
129 
138  *element_array,
139  size_t new_count);
140 
147  t8_element_array_t *src);
148 
155 
163  *element_array,
164  size_t count);
165 
173  *element_array,
174  t8_locidx_t index);
175 
183  *element_array, int index);
184 
190  *element_array);
191 
197  *element_array);
203  *element_array);
204 
211  *element_array);
212 
218  *element_array);
219 
226  *element_array);
227 
235  *element_array);
236 
237 T8_EXTERN_C_END ();
238 
239 #endif /* !T8_CONTAINERS_HXX */
This struct holds virtual functions for a particular element class.
Definition: t8_element_cxx.hxx:47
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:94
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:72
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:86
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:295
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:149
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:58
t8_element_t * t8_element_array_push(t8_element_array_t *element_array)
Enlarge an array by one element.
Definition: t8_containers.cxx:212
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:236
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:123
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:274
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:267
size_t t8_element_array_get_count(t8_element_array_t *element_array)
Return the number of elements stored in a t8_element_array_t.
Definition: t8_containers.cxx:260
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:287
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:182
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:253
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:203
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:302
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:102
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:223
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:137
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:245
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