GNU Astronomy Utilities


Previous: , Up: Linked lists   [Contents][Index]


10.3.7.9 List of 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.

Function:
void
gal_list_data_add (gal_data_t **list, gal_data_t *newnode)

Add an already allocated dataset (newnode) to top of list. In this example multiple images are linked together as a list:

size_t minmapsize=-1;
gal_data_t *tmp, *list=NULL;
tmp = gal_fits_img_read("file1.fits", "1", minmapsize);
gal_list_data_add( &list, tmp );
tmp = gal_fits_img_read("file2.fits", "1", minmapsize);
gal_list_data_add( &list, tmp );
Function:
void
gal_list_data_add_alloc (gal_data_t **list, void *array, uint8_t type, size_t ndim, size_t *dsize, struct wcsprm *wcs, int clear, size_t minmapsize, char *name, char *unit, char *comment)

Allocate a new dataset (with gal_data_alloc in Dataset size and 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.

Function:
gal_data_t *
gal_list_data_pop (gal_data_t **list)

Pop the top node from list and return it.

Function:
void
gal_list_data_reverse (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.

Function:
size_t
gal_list_data_number (gal_data_t *list)

Return the number of nodes in list.

Function:
void
gal_list_data_free (gal_data_t *list)

Free all the datasets in list along with all the allocated spaces in each.


Previous: , Up: Linked lists   [Contents][Index]