Main Page | Data Structures | File List | Data Fields | Globals

mr_vector.c File Reference

#include <stdlib.h>
#include <string.h>
#include "mr_error.h"
#include "mr_vector.h"

Defines

#define PRE_ALLOCATED_SIZE   2
#define FACTOR_INCREMENT_SIZE   2

Functions

MrVectormr_vector_new ()
MrVectormr_vector_new_init (unsigned int n, mr_func_init_t func)
MrVectormr_vector_new_n (unsigned int n)
void mr_vector_free (void *o)
void * mr_vector_get (MrVector *v, unsigned int pos)
void mr_vector_set (MrVector *v, unsigned int pos, void *data)
short int mr_vector_resize (MrVector *v, unsigned int n)
short int mr_vector_append (MrVector *v, void *data)
short int mr_vector_append_vector (MrVector *dst, MrVector *src)
short int mr_vector_remove (MrVector *v, unsigned int pos)
short int mr_vector_remove_range (MrVector *v, unsigned int start, unsigned int end)
void mr_vector_apply (MrVector *v, mr_func_apply_t func)
void mr_vector_apply_range (MrVector *v, mr_func_apply_t func, unsigned int start, unsigned int end)
void mr_vector_fill (MrVector *v, void *data)
void mr_vector_init (MrVector *v, mr_func_init_t func)
void mr_vector_sort (MrVector *v, mr_func_predicat_t func)
unsigned int mr_vector_contain (MrVector *v, void *p)

Define Documentation

#define FACTOR_INCREMENT_SIZE   2
 

#define PRE_ALLOCATED_SIZE   2
 


Function Documentation

short int mr_vector_append MrVector v,
void *  data
 

Append a new element at the end of the vector. Returns 0 in case of errors.

short int mr_vector_append_vector MrVector dst,
MrVector src
 

Append the elements of the second vector to the first one. Returns 0 in case of errors.

void mr_vector_apply MrVector v,
mr_func_apply_t  func
 

Apply a simple function on each vector element. it's equivalent to apply the range version to [O,SIZE-1]

void mr_vector_apply_range MrVector v,
mr_func_apply_t  func,
unsigned int  start,
unsigned int  end
 

Apply a simple function on a range of vector elements.

unsigned int mr_vector_contain MrVector v,
void *  p
 

Test if p is conatined in the vector return -1 or the index of the first occurency

void mr_vector_fill MrVector v,
void *  data
 

Set all the data element with specified data.

void mr_vector_free void *  v  ) 
 

Free a vector that is remove all its element. DO NOT FREE THE DATA CONTAINED IN EACH ELEMENT

void* mr_vector_get MrVector v,
unsigned int  pos
 

Get a particular element.

void mr_vector_init MrVector v,
mr_func_init_t  func
 

Set all the data element widh specified function.

MrVector* mr_vector_new  ) 
 

Allocate a new empty vector.

MrVector* mr_vector_new_init unsigned int  n,
mr_func_init_t  func
 

Allocate a new vector with elements inititalized by a specified function.

MrVector* mr_vector_new_n unsigned int  n  ) 
 

Allocate a new vector with a pre-allocated number of elements.

short int mr_vector_remove MrVector v,
unsigned int  pos
 

Remove an element from the vector. Returns 0 in case of errors. it's equivalent to apply the range version to [POS,POS]

short int mr_vector_remove_range MrVector v,
unsigned int  start,
unsigned int  end
 

Remove a range of element from the vector. Returns 0 in case of errors.

short int mr_vector_resize MrVector v,
unsigned int  n
 

Resize a previously created vector. Returns 0 in case of errors. New allocated elements have no default values.

void mr_vector_set MrVector v,
unsigned int  pos,
void *  data
 

Set a particular element.

void mr_vector_sort MrVector v,
mr_func_predicat_t  func
 

Sort vector with a the predicat function


Generated on Sun Apr 9 17:29:41 2006 for MusicReco by  doxygen 1.4.4