s3_arraylist.h File Reference

#include "sphinx3_export.h"

Go to the source code of this file.

Classes

struct  s3_arraylist_s

Defines

#define S3_ARRAYLIST_DEFAULT_SIZE   16

Typedefs

typedef struct s3_arraylist_s s3_arraylist_t

Functions

void s3_arraylist_init (s3_arraylist_t *_arraylist)
void s3_arraylist_init_size (s3_arraylist_t *_arraylist, int _size)
void s3_arraylist_close (s3_arraylist_t *_arraylist)
void s3_arraylist_clear (s3_arraylist_t *_arraylist)
void s3_arraylist_set (s3_arraylist_t *_arraylist, int _pos, void *_ptr)
void * s3_arraylist_get (s3_arraylist_t *_arraylist, int _pos)
void * s3_arraylist_replace (s3_arraylist_t *_arraylist, int _pos, void *_ptr)
void * s3_arraylist_remove (s3_arraylist_t *_arraylist, int _pos)
void s3_arraylist_insert (s3_arraylist_t *_arraylist, int _pos, void *_ptr)
void s3_arraylist_append (s3_arraylist_t *_arraylist, void *_ptr)
void s3_arraylist_prepend (s3_arraylist_t *_arraylist, void *_ptr)
void * s3_arraylist_pop (s3_arraylist_t *_arraylist)
void * s3_arraylist_dequeue (s3_arraylist_t *_arraylist)
S3DECODER_EXPORT int s3_arraylist_count (s3_arraylist_t *_arraylist)
void ** s3_arraylist_to_array (s3_arraylist_t *_arraylist)

Define Documentation

#define S3_ARRAYLIST_DEFAULT_SIZE   16

Typedef Documentation


Function Documentation

void s3_arraylist_append ( s3_arraylist_t _arraylist,
void *  _ptr 
)

Append a new element to the end of the vector. The size of the vector will expand if needed.

Parameters:
_arraylist The vector to be operated on.
_ptr The pointer to the new element.
void s3_arraylist_clear ( s3_arraylist_t _arraylist  ) 

Clear the content of the vector and set the element count to 0. The pointers (or data) contained in the vector are not freed. The user is responsible for freeing them. The array is immediately usable again.

Parameters:
_arraylist The vector to be cleared.
void s3_arraylist_close ( s3_arraylist_t _arraylist  ) 

Close the vector and free any internally allocated memory. The vector structure itself is not freed. The vector must be re-initialized before it can be used again.

Parameters:
_arraylist The vector to be closed.
S3DECODER_EXPORT int s3_arraylist_count ( s3_arraylist_t _arraylist  ) 

Returns the element count.

Parameters:
_arraylist The vector to count..
Returns:
The size of the vector.

Referenced by main().

void* s3_arraylist_dequeue ( s3_arraylist_t _arraylist  ) 

Remove the element at the front of the vector.

Parameters:
_arraylist The vector to be operated on.
Returns:
The pointer to the removed element.
void* s3_arraylist_get ( s3_arraylist_t _arraylist,
int  _pos 
)

Get the element at a particular index. Accessing out-of-bound indices will cause an error.

Parameters:
_arraylist The vector to be operated on.
_pos The position of the requested element.
Returns:
The pointer to the requested element.
void s3_arraylist_init ( s3_arraylist_t _arraylist  ) 

Initializes the vector to a default size (1). A vector must be initialized before it can be used.

Parameters:
_arraylist The vector to be initialized.
void s3_arraylist_init_size ( s3_arraylist_t _arraylist,
int  _size 
)

Initializes the vector to a certain size. A vector must be initialized before it can be used.

Parameters:
_arraylist The vector to be initialized.
_size The size to initialize the vector to.
void s3_arraylist_insert ( s3_arraylist_t _arraylist,
int  _pos,
void *  _ptr 
)

Insert the element at a position and shift the remaining element up. The size of the vector will expand if needed. (NOT IMPLEMENTED)

Parameters:
_arraylist The vector to be operated on.
_pos The position to insert the new element.
_ptr The pointer to the new element.
void* s3_arraylist_pop ( s3_arraylist_t _arraylist  ) 

Remove the element at the end of the vector.

Parameters:
_arraylist The vector to be operated on.
Returns:
The pointer to the removed element.
void s3_arraylist_prepend ( s3_arraylist_t _arraylist,
void *  _ptr 
)

Prepend a new element to the head of the vector. The size of the vector will expand if needed.

Parameters:
_arraylist The vector to be operated on.
_ptr The pointer to the new element.
void* s3_arraylist_remove ( s3_arraylist_t _arraylist,
int  _pos 
)

Remove the element at a position and shift the remaining elements down. (NOT IMPLEMENTED)

Parameters:
_arraylist The vector to be operated on.
_pos The position of the element to be removed.
Returns:
The pointer of the removed element.
void* s3_arraylist_replace ( s3_arraylist_t _arraylist,
int  _pos,
void *  _ptr 
)

Replace the element at a particular index (and return the previous value). Replacing out-of-bound indices will cause an error.

Parameters:
_arraylist The vector to be operated on.
_pos The position of the replacement.
_ptr The pointer to the new element.
Returns:
The pointer of the previous value.
void s3_arraylist_set ( s3_arraylist_t _arraylist,
int  _pos,
void *  _ptr 
)

Set the element at a particular index. The element can be NULL. The previous value is not saved nor freed. The user is responsible for keeping track of the previous value if it is needed.

This function automatically expands the size of the vector if needed. If the position is greater than the previous element count, the element count is updated.

Parameters:
_arraylist The vector to be operated on.
_pos The position to set the element.
_ptr The pointer to the new element.
void** s3_arraylist_to_array ( s3_arraylist_t _arraylist  ) 

Returns a read-only plain-old array of the elements in the vector.

Parameters:
_arraylist The vector to be converted into array.
Returns:
The plain-old array.
0 for success, -1 for failure.

Generated on 7 Mar 2010 by  doxygen 1.6.1