gal_data_t
¶Gnuastro’s generic data container has a next
element which enables it to be used as a singly-linked list (see Generic data container (gal_data_t
)).
The ability to connect the different data containers offers great advantages.
For example, each column in a table in an independent dataset: with its own name, units, numeric data type (see Numeric data types).
Another application is in Tessellating an input dataset into separate tiles or only studying particular regions, or tiles, of a larger dataset (see Tessellation and Tessellation library (tile.h)).
Each independent tile over the dataset can be connected to the others as a linked list and thus any number of tiles can be represented with one variable.
void
(gal_data_t **list
, gal_data_t *newnode
)
¶Add an already allocated dataset (newnode
) to top of list
.
Note that if newnode->next!=NULL
(newnode
is itself a list), then list
will be added to its end.
In this example multiple images are linked together as a list:
int quietmmap=1; size_t minmapsize=-1; gal_data_t *tmp, *list=NULL; tmp = gal_fits_img_read("file1.fits", "1", minmapsize, quietmmap, NULL); gal_list_data_add( &list, tmp ); tmp = gal_fits_img_read("file2.fits", "1", minmapsize, quietmmap, NULL); gal_list_data_add( &list, tmp );
void
(gal_data_t **list
, void *array
, uint8_t type
, size_t ndim
, size_t *dsize
, struct wcsprm *wcs
, int clear
, size_t minmapsize
, int quietmmap
, char *name
, char *unit
, char *comment
)
¶Allocate a new dataset (with gal_data_alloc
in Dataset allocation) and put it as the first element of list
.
Note that if this is the first node to be added to the list, list
must be NULL
.
gal_data_t *
(gal_data_t **list
)
¶Pop the top node from list
and return it.
void
(gal_data_t **list
, gal_data_t *node
)
¶Remove node
from the given list
.
After finding the given node, this function will just set node->next=NULL
and correct the next
node of its previous element to its next element (thus “removing” it from the list).
If node
doesn’t exist in the list, this function won’t make any change to list.
gal_data_t *
(gal_data_t *list
, char *name
)
¶Select the dataset within the list, that has a name
element that is identical (case-sensitive) to the given name
.
If not found, a NULL
pointer will be returned.
Note that this dataset will not be popped from the list, only a pointer to it will be returned and if you free it or change its next
element, it may harm your original list.
gal_data_t *
(gal_data_t *table
, char *idstr
, size_t *index
)
¶Select the dataset within the list that can be identified with the string given to idstr
(which can be a counter, starting from 1, or a name).
If not found, a NULL
pointer will be returned.
Note that this dataset will not be popped from the list, only a pointer to it will be returned and if you free it or change its next
element, it may harm your original list.
void
(gal_data_t **list
)
¶Reverse the order of the list such that the top node in the list before calling this function becomes the bottom node after it.
gal_data_t **
(gal_data_t *list
, size_t *num
)
¶Allocate and return an array of gal_data_t *
pointers with the same number of elements as the nodes in list
.
The pointers will be put in the same order that the list is parsed.
Hence the N-th element in the array will point to the same dataset that the N-th node in the list points to.
size_t
(gal_data_t *list
)
¶Return the number of nodes in list
.
gal_data_t *
(gal_data_t *list
)
¶Return a pointer to the last node in list
.
void
(gal_data_t *list
)
¶Free all the datasets in list
along with all the allocated spaces in
each.
GNU Astronomy Utilities 0.23 manual, July 2024.