Defines | Functions

sofia-sip/su_vector.h File Reference

Vector interface. More...

#include <sofia-sip/su_alloc.h>
Include dependency graph for su_vector.h:

Go to the source code of this file.

Defines

#define SU_VECTOR_H
 Defined when <sofia-sip/su_vector.h> has been included.

Functions

su_vector_t * su_vector_create (su_home_t *home, su_free_func_t free_f))
 Create a vector.
void su_vector_destroy (su_vector_t *)
 Destroy a vector.
int su_vector_insert (su_vector_t *vector, usize_t index, void *item)
 Insert an item to vector.
int su_vector_remove (su_vector_t *vector, usize_t index)
 Remove an item from vector.
int su_vector_append (su_vector_t *, void *item)
 Append a item to vector.
void * su_vector_item (su_vector_t const *, usize_t i)
 Get a numbered item from vector.
usize_t su_vector_len (su_vector_t const *l)
 Get number of items in vector.
int su_vector_empty (su_vector_t *vector)
 Remove all items from vector.
void ** su_vector_get_array (su_vector_t *))
 Get an array of pointers from the vector.
void su_vector_free_array (su_vector_t *, void *array[])
 Free the array.

Detailed Description

Vector interface.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>
Date:
Created: Fri Sep 27 14:31:15 2002 ppessi

Define Documentation

#define SU_VECTOR_H

Defined when <sofia-sip/su_vector.h> has been included.


Function Documentation

int su_vector_append ( su_vector_t *  vector,
void *  item 
)

Append a item to vector.

Append a item to vector.

The function su_vector_append() appends an item to the vector.

Parameters:
vector pointer to a vector object
item item to be appended
Return values:
0 if successful
-1 upon an error
su_vector_t* su_vector_create ( su_home_t home,
su_free_func_t  free_func 
)

Create a vector.

The function su_vector_create() creates a pointer vector object. The vector is initially empty. The function clones a memory home for the vector object from home. If a free_func is provided then that will be used to free the individual nodes (NULL if not used).

void su_vector_destroy ( su_vector_t *  vector  ) 

Destroy a vector.

The function su_vector_destroy() destroys a vector and frees all its nodes if a freeing function is available

int su_vector_empty ( su_vector_t *  vector  ) 

Remove all items from vector.

The function su_vector_empty() removes all items from the vector.

Parameters:
vector pointer to a vector object
Return values:
0 if successful
-1 upon an error
void** su_vector_get_array ( su_vector_t *  vector  ) 

Get an array of pointers from the vector.

Get an array of pointers from the vector.

The function su_vector_get_array() returns an array of pointer. The length of the array is always one longer than the length of the vector, and the last item in the returned array is always NULL.

Parameters:
vector pointer to a vector object
Returns:
Pointer to array, or NULL if error occurred.
int su_vector_insert ( su_vector_t *  vector,
usize_t  index,
void *  item 
)

Insert an item to vector.

The function su_vector_insert() inserts an item to the vector. The items after the index will be moved further within the vector.

Parameters:
vector pointer to a vector object
item item to be appended
index index for the new item
Return values:
0 when successful
-1 upon an error
void* su_vector_item ( su_vector_t const *  vector,
usize_t  i 
)

Get a numbered item from vector.

Get a numbered item from vector.

The function su_vector_item() returns a numbered item from vector. The numbering starts from 0.

Parameters:
vector pointer to a vector object
i index
Returns:
Pointer, if item exists, or NULL upon an error.
usize_t su_vector_len ( su_vector_t const *  l  ) 

Get number of items in vector.

Get number of items in vector.

The function su_vector_len() returns the number of items in the vector.

int su_vector_remove ( su_vector_t *  vector,
usize_t  index 
)

Remove an item from vector.

The function su_vector_remove() removes an item from the vector. The items after the index will be moved backwards within the vector.

Parameters:
vector pointer to a vector object
index index for the removed item
Return values:
0 when successful
-1 upon an error
 All Data Structures Files Functions Variables Typedefs Enumerator Defines

Sofia-SIP 1.12.11 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.