Loading...
Searching...
No Matches
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.

## Macros

#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.nosp@m..Pes.nosp@m.si@no.nosp@m.kia..nosp@m.com

Date
  Created: Fri Sep 27 14:31:15 2002 ppessi

## Function Documentation

## su_vector_append()

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_create()

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).

## su_vector_destroy()

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

## su_vector_empty()

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

## su_vector_get_array()

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.

## su_vector_insert()

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

## su_vector_item()

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.

## su_vector_len()

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.

## su_vector_remove()

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

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