chunkidset.h File Reference

Structure containing a set of chunk IDs. More...

Go to the source code of this file.

Typedefs

typedef struct chunkID_set ChunkIDSet

Enumerations

enum  chunkID_set_encoding_type { bitmap, priority }

Functions

struct chunkID_set * chunkID_set_init (const char *config)
 Allocate a chunk ID set.
int chunkID_set_add_chunk (struct chunkID_set *h, int chunk_id)
 Add a chunk ID to the set.
int chunkID_set_size (const struct chunkID_set *h)
 Get the set size.
int chunkID_set_get_chunk (const struct chunkID_set *h, int i)
 Get a chunk ID from a set.
int chunkID_set_check (const struct chunkID_set *h, int chunk_id)
 Check if a chunk ID is in a set.
int chunkID_set_union (struct chunkID_set *h, struct chunkID_set *a)
void chunkID_set_clear (struct chunkID_set *h, int size)
void chunkID_set_free (struct chunkID_set *h)
 Clear a set and free all associated memory.
int chunkID_set_get_earliest (const struct chunkID_set *h)
int chunkID_set_get_latest (const struct chunkID_set *h)

Detailed Description

Structure containing a set of chunk IDs.

The Chunk ID Set is an abstract data structure that can contain a set of (chunk ID, priority) couples. Few simple operations for adding chunk IDs in a set, for getting the chunk IDs present in a set, for allocating a set, and for clearing a set are provided.


Typedef Documentation

typedef struct chunkID_set ChunkIDSet

Opaque data type representing a Chunk ID Set


Function Documentation

int chunkID_set_add_chunk ( struct chunkID_set *  h,
int  chunk_id 
)

Add a chunk ID to the set.

Insert a chunk ID, and its associated priority (the priority is assumed to depend on the insertion order), to the set. If the chunk ID is already in the set, nothing happens.

Parameters:
h a pointer to the set where the chunk ID has to be added
chunk_id the ID of the chunk to be inserted in the set
Returns:
> 0 if the chunk ID is correctly inserted in the set, 0 if chunk_id is already in the set, < 0 on error
int chunkID_set_check ( const struct chunkID_set *  h,
int  chunk_id 
)

Check if a chunk ID is in a set.

Parameters:
h a pointer to the set
chunk_id the chunk ID we are searching for
Returns:
the priority of the chunk ID if it is present in the set, < 0 on error or if the chunk ID is not in the set
void chunkID_set_clear ( struct chunkID_set *  h,
int  size 
)

Clear a set

Remove all the chunk IDs from a set.

Parameters:
h a pointer to the set
size the expected number of chunk IDs that will be stored in the set; 0 if such a number is not known.
void chunkID_set_free ( struct chunkID_set *  h  ) 

Clear a set and free all associated memory.

Parameters:
h a pointer to the set
int chunkID_set_get_chunk ( const struct chunkID_set *  h,
int  i 
)

Get a chunk ID from a set.

Return the i^th chunk ID from the set. The chunk's priority is assumed to depend on i.

Parameters:
h a pointer to the set
i the index of the chunk ID to be returned
Returns:
the i^th chunk ID in the set in case of success, or < 0 on error (in case of error, priority is not meaningful)
struct chunkID_set* chunkID_set_init ( const char *  config  )  [read]

Allocate a chunk ID set.

Create an empty chunk ID set, and return a pointer to it.

Parameters:
config a configuration string containing tags which describe the chunk ID set. For example, the "size" tag indicates the expected number of chunk IDs that will be stored in the set; 0 or not present if such a number is not known.
Returns:
the pointer to the new set on success, NULL on error
int chunkID_set_size ( const struct chunkID_set *  h  ) 

Get the set size.

Return the number of chunk IDs present in a set.

Parameters:
h a pointer to the set
Returns:
the number of chunk IDs in the set, or < 0 on error
int chunkID_set_union ( struct chunkID_set *  h,
struct chunkID_set *  a 
)

Add chunks from a chunk ID set to another one

Insert all chunk from a chunk ID set into another one. Priority is kept in the old one. New chunks from the added one are added with lower priorities, but keeping their order.

Parameters:
h a pointer to the set where the chunk ID has to be added
a a pointer to the set which has to be added
Returns:
> 0 if the chunk ID is correctly inserted in the set, 0 if chunk_id is already in the set, < 0 on error
Generated on Mon Jul 12 16:16:52 2010 for GRAPES by  doxygen 1.6.3