GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sparse.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <grass/linkm.h>
#include <grass/bitmap.h>
Include dependency graph for sparse.c:

Go to the source code of this file.

Macros

#define BM_col_to_byte(x)   ((x)/8)
 
#define BM_col_to_bit(x)   ((x)%8)
 

Functions

struct BM * BM_create_sparse (int x, int y)
 Create a sparse bitmap of dimension 'x'/'y'. More...
 
int BM_destroy_sparse (struct BM *map)
 Destroy sparse bitmap and free all associated memory. More...
 
int BM_set_sparse (struct BM *map, int x, int y, int val)
 Set sparse bitmap value to 'val' at location 'x'/'y'. More...
 
int BM_get_sparse (struct BM *map, int x, int y)
 Returns sparse bitmap value at location 'x'/'y'. More...
 
int BM_get_map_size_sparse (struct BM *map)
 Returns size of sparse bitmap in bytes. More...
 
int BM_dump_map_sparse (struct BM *map)
 Debugging code to dump out structure of links. More...
 
int BM_dump_map_row_sparse (struct BM *map, int y)
 Debugging code to dump out structure of links for single row. More...
 
int BM_file_write_sparse (FILE *fp, struct BM *map)
 Write sparse bitmap matrix out to disk file 'fp'. NOTE: 'fp' must already be opened and later closed by user. More...
 

Macro Definition Documentation

#define BM_col_to_bit (   x)    ((x)%8)

Definition at line 27 of file sparse.c.

#define BM_col_to_byte (   x)    ((x)/8)

Definition at line 26 of file sparse.c.

Function Documentation

struct BM* BM_create_sparse ( int  x,
int  y 
)

Create a sparse bitmap of dimension 'x'/'y'.

Returns bitmap structure or NULL on error

Parameters
x
y
Returns
struct BM

Definition at line 44 of file sparse.c.

References count, link_init(), link_new(), link_set_chunk_size(), malloc(), NULL, and y.

Referenced by BM_create(), and main().

int BM_destroy_sparse ( struct BM *  map)

Destroy sparse bitmap and free all associated memory.

Returns 0

Parameters
map
Returns
int

Definition at line 90 of file sparse.c.

References free(), link_cleanup(), link_dispose(), NULL, and VOID_T.

Referenced by BM_destroy().

int BM_dump_map_row_sparse ( struct BM *  map,
int  y 
)

Debugging code to dump out structure of links for single row.

Returns 0

Parameters
map
y
Returns
int

Definition at line 332 of file sparse.c.

References NULL, and y.

Referenced by main().

int BM_dump_map_sparse ( struct BM *  map)

Debugging code to dump out structure of links.

Returns 0

Parameters
map
Returns
int

Definition at line 302 of file sparse.c.

References NULL.

int BM_file_write_sparse ( FILE *  fp,
struct BM *  map 
)

Write sparse bitmap matrix out to disk file 'fp'. NOTE: 'fp' must already be opened and later closed by user.

Returns 0 on success or -1 on error

Parameters
fp
map
Returns
int

Definition at line 364 of file sparse.c.

References NULL, and y.

Referenced by BM_file_write().

int BM_get_map_size_sparse ( struct BM *  map)

Returns size of sparse bitmap in bytes.

Parameters
map
Returns
int

Definition at line 272 of file sparse.c.

References NULL, and tools::size.

Referenced by BM_get_map_size().

int BM_get_sparse ( struct BM *  map,
int  x,
int  y 
)

Returns sparse bitmap value at location 'x'/'y'.

Returns value or -1 on error

Parameters
map
x
y
Returns
int

Definition at line 246 of file sparse.c.

References cur_x, and NULL.

Referenced by BM_get().

int BM_set_sparse ( struct BM *  map,
int  x,
int  y,
int  val 
)

Set sparse bitmap value to 'val' at location 'x'/'y'.

Returns 0

Parameters
map
x
y
val
Returns
int

Definition at line 128 of file sparse.c.

References cur_x, link_dispose(), link_new(), NULL, and VOID_T.

Referenced by BM_set().