GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-d6dec75dd4
vector/Vlib/list.c File Reference

Vector library - list definition. More...

#include <stdlib.h>
#include <grass/vector.h>
Include dependency graph for vector/Vlib/list.c:

Go to the source code of this file.

Functions

struct ilistVect_new_list (void)
 Creates and initializes a struct ilist. More...
 
int Vect_reset_list (struct ilist *list)
 Reset ilist structure. More...
 
void Vect_destroy_list (struct ilist *list)
 Frees all memory associated with a struct ilist, including the struct itself. More...
 
int Vect_list_append (struct ilist *list, int val)
 Append new item to the end of list if not yet present. More...
 
int Vect_list_append_list (struct ilist *alist, const struct ilist *blist)
 Append new items to the end of list if not yet present. More...
 
int Vect_list_delete (struct ilist *list, int val)
 Remove a given value (item) from list. More...
 
int Vect_list_delete_list (struct ilist *alist, const struct ilist *blist)
 Delete list from existing list. More...
 
int Vect_val_in_list (const struct ilist *list, int val)
 Find a given item in the list. More...
 
struct boxlistVect_new_boxlist (int have_boxes)
 Creates and initializes a struct boxlist. More...
 
int Vect_reset_boxlist (struct boxlist *list)
 Reset boxlist structure. More...
 
void Vect_destroy_boxlist (struct boxlist *list)
 Frees all memory associated with a struct boxlist, including the struct itself. More...
 
int Vect_boxlist_append (struct boxlist *list, int id, const struct bound_box *box)
 Append new item to the end of list if not yet present. More...
 
int Vect_boxlist_append_boxlist (struct boxlist *alist, const struct boxlist *blist)
 Append new items to the end of list if not yet present. More...
 
int Vect_boxlist_delete (struct boxlist *list, int id)
 Remove a given value (item) from list. More...
 
int Vect_boxlist_delete_boxlist (struct boxlist *alist, const struct boxlist *blist)
 Delete list from existing list. More...
 
int Vect_val_in_boxlist (const struct boxlist *list, int id)
 Find a given item in the list. More...
 

Detailed Description

Vector library - list definition.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL, probably Dave Gerdes or Mike Higgins.
Update to GRASS 5.7 Radim Blazek and David D. Gray
Update to GRASS 7 Markus Metz

Definition in file vector/Vlib/list.c.

Function Documentation

◆ Vect_boxlist_append()

int Vect_boxlist_append ( struct boxlist list,
int  id,
const struct bound_box box 
)

Append new item to the end of list if not yet present.

Parameters
[in,out]listpointer to ilist structure
idnew item to append to the end of list
boxbounding box
Returns
0 on success
1 on error

Definition at line 287 of file vector/Vlib/list.c.

References G_realloc, and NULL.

Referenced by Vect_boxlist_append_boxlist().

◆ Vect_boxlist_append_boxlist()

int Vect_boxlist_append_boxlist ( struct boxlist alist,
const struct boxlist blist 
)

Append new items to the end of list if not yet present.

Parameters
[in,out]alistpointer to boxlist structure where items will be appended
blistpointer to boxlist structure with new items
Returns
0 on success
1 on error

Definition at line 330 of file vector/Vlib/list.c.

References bound_box::B, boxlist::box, bound_box::E, boxlist::have_boxes, boxlist::id, bound_box::N, boxlist::n_values, NULL, bound_box::S, bound_box::T, Vect_boxlist_append(), and bound_box::W.

◆ Vect_boxlist_delete()

int Vect_boxlist_delete ( struct boxlist list,
int  id 
)

Remove a given value (item) from list.

Parameters
[in,out]listpointer to boxlist structure
idto remove
Returns
0 on success
1 on error

Definition at line 362 of file vector/Vlib/list.c.

References NULL.

Referenced by Vect_boxlist_delete_boxlist().

◆ Vect_boxlist_delete_boxlist()

int Vect_boxlist_delete_boxlist ( struct boxlist alist,
const struct boxlist blist 
)

Delete list from existing list.

Parameters
[in,out]alistpointer to original boxlist structure,
blistpointer to boxlist structure with items to delete
Returns
0 on success
1 on error

Definition at line 394 of file vector/Vlib/list.c.

References boxlist::id, boxlist::n_values, NULL, and Vect_boxlist_delete().

◆ Vect_destroy_boxlist()

void Vect_destroy_boxlist ( struct boxlist list)

Frees all memory associated with a struct boxlist, including the struct itself.

Parameters
[in,out]listpointer to ilist structure

Definition at line 264 of file vector/Vlib/list.c.

References G_free(), and NULL.

◆ Vect_destroy_list()

void Vect_destroy_list ( struct ilist list)

Frees all memory associated with a struct ilist, including the struct itself.

Parameters
[in,out]listpointer to ilist structure

Definition at line 69 of file vector/Vlib/list.c.

References G_free(), and NULL.

◆ Vect_list_append()

int Vect_list_append ( struct ilist list,
int  val 
)

Append new item to the end of list if not yet present.

Parameters
[in,out]listpointer to ilist structure
valnew item to append to the end of list
Returns
0 on success
1 on error

Definition at line 89 of file vector/Vlib/list.c.

References G_realloc, and NULL.

Referenced by Vect_field_cat_get(), and Vect_list_append_list().

◆ Vect_list_append_list()

int Vect_list_append_list ( struct ilist alist,
const struct ilist blist 
)

Append new items to the end of list if not yet present.

Parameters
[in,out]alistpointer to ilist structure where items will be appended
blistpointer to ilist structure with new items
Returns
0 on success
1 on error

Definition at line 123 of file vector/Vlib/list.c.

References ilist::n_values, NULL, ilist::value, and Vect_list_append().

◆ Vect_list_delete()

int Vect_list_delete ( struct ilist list,
int  val 
)

Remove a given value (item) from list.

Parameters
[in,out]listpointer to ilist structure
valto remove
Returns
0 on success
1 on error

Definition at line 145 of file vector/Vlib/list.c.

References NULL.

Referenced by Vect_list_delete_list().

◆ Vect_list_delete_list()

int Vect_list_delete_list ( struct ilist alist,
const struct ilist blist 
)

Delete list from existing list.

Parameters
[in,out]alistpointer to original ilist structure,
blistpointer to ilist structure with items to delete
Returns
0 on success
1 on error

Definition at line 174 of file vector/Vlib/list.c.

References ilist::n_values, NULL, ilist::value, and Vect_list_delete().

◆ Vect_new_boxlist()

struct boxlist* Vect_new_boxlist ( int  have_boxes)

Creates and initializes a struct boxlist.

This structure is used as container for bounding boxes with id. The library routines handle all memory allocation.

Parameters
have_boxesif set to 0, the list will hold only ids and no boxes
Returns
pointer to struct boxlist
NULL on error

Definition at line 224 of file vector/Vlib/list.c.

References boxlist::alloc_values, boxlist::box, G_malloc, boxlist::have_boxes, boxlist::id, boxlist::n_values, and NULL.

Referenced by Vect_attach_isles(), and Vect_find_area().

◆ Vect_new_list()

struct ilist* Vect_new_list ( void  )

Creates and initializes a struct ilist.

This structure is used as container for integer values. The library routines handle all memory allocation.

Returns
pointer to struct ilist
NULL on error

Definition at line 31 of file vector/Vlib/list.c.

References ilist::alloc_values, G_malloc, ilist::n_values, NULL, and ilist::value.

Referenced by NetA_betweenness_closeness(), Vect_find_node(), Vect_select_areas_by_polygon(), and Vedit_extend_lines().

◆ Vect_reset_boxlist()

int Vect_reset_boxlist ( struct boxlist list)

Reset boxlist structure.

To make sure boxlist structure is clean to be re-used. List must have previously been created with Vect_new_boxlist().

Parameters
[in,out]listpointer to struct boxlist
Returns
0

Definition at line 251 of file vector/Vlib/list.c.

◆ Vect_reset_list()

int Vect_reset_list ( struct ilist list)

Reset ilist structure.

To make sure ilist structure is clean to be re-used. List must have previously been created with Vect_new_list().

Parameters
[in,out]listpointer to struct ilist
Returns
0

Definition at line 56 of file vector/Vlib/list.c.

Referenced by Vect_field_cat_get(), Vect_select_areas_by_polygon(), Vect_select_nodes_by_box(), and Vect_spatial_index_select().

◆ Vect_val_in_boxlist()

int Vect_val_in_boxlist ( const struct boxlist list,
int  id 
)

Find a given item in the list.

Parameters
listpointer to boxlist structure
idvalue of item
Returns
1 if an item is found
0 no found item in the list

Definition at line 417 of file vector/Vlib/list.c.

References NULL.

◆ Vect_val_in_list()

int Vect_val_in_list ( const struct ilist list,
int  val 
)

Find a given item in the list.

Parameters
listpointer to ilist structure
valvalue of item
Returns
1 if an item is found
0 no found item in the list

Definition at line 196 of file vector/Vlib/list.c.

References NULL.