Blame include/complib/cl_vector.h

Packit Service 54dbc3
/*
Packit Service 54dbc3
 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
Packit Service 54dbc3
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit Service 54dbc3
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
Packit Service 54dbc3
 *
Packit Service 54dbc3
 * This software is available to you under a choice of one of two
Packit Service 54dbc3
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit Service 54dbc3
 * General Public License (GPL) Version 2, available from the file
Packit Service 54dbc3
 * COPYING in the main directory of this source tree, or the
Packit Service 54dbc3
 * OpenIB.org BSD license below:
Packit Service 54dbc3
 *
Packit Service 54dbc3
 *     Redistribution and use in source and binary forms, with or
Packit Service 54dbc3
 *     without modification, are permitted provided that the following
Packit Service 54dbc3
 *     conditions are met:
Packit Service 54dbc3
 *
Packit Service 54dbc3
 *      - Redistributions of source code must retain the above
Packit Service 54dbc3
 *        copyright notice, this list of conditions and the following
Packit Service 54dbc3
 *        disclaimer.
Packit Service 54dbc3
 *
Packit Service 54dbc3
 *      - Redistributions in binary form must reproduce the above
Packit Service 54dbc3
 *        copyright notice, this list of conditions and the following
Packit Service 54dbc3
 *        disclaimer in the documentation and/or other materials
Packit Service 54dbc3
 *        provided with the distribution.
Packit Service 54dbc3
 *
Packit Service 54dbc3
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit Service 54dbc3
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit Service 54dbc3
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit Service 54dbc3
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit Service 54dbc3
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit Service 54dbc3
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit Service 54dbc3
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit Service 54dbc3
 * SOFTWARE.
Packit Service 54dbc3
 *
Packit Service 54dbc3
 */
Packit Service 54dbc3
Packit Service 54dbc3
/*
Packit Service 54dbc3
 * Abstract:
Packit Service 54dbc3
 *	This file contains vector definitions.  Vector provides dynmically
Packit Service 54dbc3
 *	resizable array functionality.  Objects in a Vector are not relocated
Packit Service 54dbc3
 *	when the array is resized.
Packit Service 54dbc3
 */
Packit Service 54dbc3
Packit Service 54dbc3
#ifndef _CL_VECTOR_H_
Packit Service 54dbc3
#define _CL_VECTOR_H_
Packit Service 54dbc3
Packit Service 54dbc3
#include <complib/cl_qlist.h>
Packit Service 54dbc3
Packit Service 54dbc3
#ifdef __cplusplus
Packit Service 54dbc3
#  define BEGIN_C_DECLS extern "C" {
Packit Service 54dbc3
#  define END_C_DECLS   }
Packit Service 54dbc3
#else				/* !__cplusplus */
Packit Service 54dbc3
#  define BEGIN_C_DECLS
Packit Service 54dbc3
#  define END_C_DECLS
Packit Service 54dbc3
#endif				/* __cplusplus */
Packit Service 54dbc3
Packit Service 54dbc3
BEGIN_C_DECLS
Packit Service 54dbc3
/****h* Component Library/Vector
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	Vector
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The Vector is a self-sizing array. Like a traditonal array, a vector
Packit Service 54dbc3
*	allows efficient constant time access to elements with a specified index.
Packit Service 54dbc3
*	A vector grows transparently as the user adds elements to the array.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	As the vector grows in size, it does not relocate existing elements in
Packit Service 54dbc3
*	memory. This allows using pointers to elements stored in a Vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Users can supply an initializer functions that allow a vector to ensure
Packit Service 54dbc3
*	that new items added to the vector are properly initialized. A vector
Packit Service 54dbc3
*	calls the initializer function on a per object basis when growing the
Packit Service 54dbc3
*	array. The initializer is optional.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	The initializer function can fail, and returns a cl_status_t. The vector
Packit Service 54dbc3
*	will call the destructor function, if provided, for an element that
Packit Service 54dbc3
*	failed initialization. If an initializer fails, a vector does not call
Packit Service 54dbc3
*	the initializer for objects in the remainder of the new memory allocation.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	The cl_vector_t structure should be treated as opaque and should be
Packit Service 54dbc3
*	manipulated only through the provided functions.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Structures:
Packit Service 54dbc3
*		cl_vector_t
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Callbacks:
Packit Service 54dbc3
*		cl_pfn_vec_init_t, cl_pfn_vec_dtor_t, cl_pfn_vec_apply_t,
Packit Service 54dbc3
*		cl_pfn_vec_find_t
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Item Manipulation:
Packit Service 54dbc3
*		cl_vector_set_obj, cl_vector_obj
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Initialization:
Packit Service 54dbc3
*		cl_vector_construct, cl_vector_init, cl_vector_destroy
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Manipulation:
Packit Service 54dbc3
*		cl_vector_get_capacity, cl_vector_set_capacity,
Packit Service 54dbc3
*		cl_vector_get_size, cl_vector_set_size, cl_vector_set_min_size
Packit Service 54dbc3
*		cl_vector_get_ptr, cl_vector_get, cl_vector_at, cl_vector_set
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Search:
Packit Service 54dbc3
*		cl_vector_find_from_start, cl_vector_find_from_end
Packit Service 54dbc3
*		cl_vector_apply_func
Packit Service 54dbc3
*********/
Packit Service 54dbc3
/****d* Component Library: Vector/cl_pfn_vec_init_t
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_pfn_vec_init_t
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_pfn_vec_init_t function type defines the prototype for functions
Packit Service 54dbc3
*	used as initializer for elements being allocated by a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
typedef cl_status_t
Packit Service 54dbc3
    (*cl_pfn_vec_init_t) (IN void *const p_element, IN void *context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[in] Pointer to an element being added to a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Context provided in a call to cl_vector_init.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	Return CL_SUCCESS to indicate that the element was initialized successfully.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Other cl_status_t values will be returned by the cl_vector_init,
Packit Service 54dbc3
*	cl_vector_set_size, and cl_vector_set_min_size functions.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	In situations where the vector's size needs to grows in order to satisfy
Packit Service 54dbc3
*	a call to cl_vector_set, a non-successful status returned by the
Packit Service 54dbc3
*	initializer callback causes the growth to stop.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	This function type is provided as function prototype reference for
Packit Service 54dbc3
*	the initializer function provided by users as an optional parameter to
Packit Service 54dbc3
*	the cl_vector_init function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_init
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****d* Component Library: Vector/cl_pfn_vec_dtor_t
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_pfn_vec_dtor_t
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_pfn_vec_dtor_t function type defines the prototype for functions
Packit Service 54dbc3
*	used as destructor for elements being deallocated from a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
typedef void
Packit Service 54dbc3
 (*cl_pfn_vec_dtor_t) (IN void *const p_element, IN void *context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[in] Pointer to an element being deallocated from a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Context provided in a call to cl_vector_init.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	This function type is provided as function prototype reference for
Packit Service 54dbc3
*	the destructor function provided by users as an optional parameter to
Packit Service 54dbc3
*	the cl_vector_init function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_init
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****d* Component Library: Vector/cl_pfn_vec_apply_t
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_pfn_vec_apply_t
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_pfn_vec_apply_t function type defines the prototype for functions
Packit Service 54dbc3
*	used to iterate elements in a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
typedef void
Packit Service 54dbc3
 (*cl_pfn_vec_apply_t) (IN const size_t index,
Packit Service 54dbc3
			IN void *const p_element, IN void *context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	index
Packit Service 54dbc3
*		[in] Index of the element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[in] Pointer to an element at the specified index in the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Context provided in a call to cl_vector_apply_func.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	This function type is provided as function prototype reference for
Packit Service 54dbc3
*	the function passed by users as a parameter to the cl_vector_apply_func
Packit Service 54dbc3
*	function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_apply_func
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****d* Component Library: Vector/cl_pfn_vec_find_t
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_pfn_vec_find_t
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_pfn_vec_find_t function type defines the prototype for functions
Packit Service 54dbc3
*	used to find elements in a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
typedef cl_status_t
Packit Service 54dbc3
    (*cl_pfn_vec_find_t) (IN const size_t index,
Packit Service 54dbc3
			  IN const void *const p_element, IN void *context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	index
Packit Service 54dbc3
*		[in] Index of the element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[in] Pointer to an element at the specified index in the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Context provided in a call to cl_vector_find_from_start or
Packit Service 54dbc3
*		cl_vector_find_from_end.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	Return CL_SUCCESS if the element was found. This stops vector iteration.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_NOT_FOUND to continue the vector iteration.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	This function type is provided as function prototype reference for the
Packit Service 54dbc3
*	function provided by users as a parameter to the cl_vector_find_from_start
Packit Service 54dbc3
*	and cl_vector_find_from_end functions.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_find_from_start, cl_vector_find_from_end
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****i* Component Library: Vector/cl_pfn_vec_copy_t
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_pfn_vec_copy_t
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_pfn_vec_copy_t function type defines the prototype for functions
Packit Service 54dbc3
*	used to copy elements in a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
typedef void
Packit Service 54dbc3
 (*cl_pfn_vec_copy_t) (IN void *const p_dest,
Packit Service 54dbc3
		       IN const void *const p_src, IN const size_t size);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_dest
Packit Service 54dbc3
*		[in] Pointer to the destination buffer into which to copy p_src.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_src
Packit Service 54dbc3
*		[in] Pointer to the destination buffer from which to copy.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	size
Packit Service 54dbc3
*		[in] Number of bytes to copy.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****s* Component Library: Vector/cl_vector_t
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_t
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	Vector structure.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	The cl_vector_t structure should be treated as opaque and should be
Packit Service 54dbc3
*	manipulated only through the provided functions.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
typedef struct _cl_vector {
Packit Service 54dbc3
	size_t size;
Packit Service 54dbc3
	size_t grow_size;
Packit Service 54dbc3
	size_t capacity;
Packit Service 54dbc3
	size_t element_size;
Packit Service 54dbc3
	cl_pfn_vec_init_t pfn_init;
Packit Service 54dbc3
	cl_pfn_vec_dtor_t pfn_dtor;
Packit Service 54dbc3
	cl_pfn_vec_copy_t pfn_copy;
Packit Service 54dbc3
	const void *context;
Packit Service 54dbc3
	cl_qlist_t alloc_list;
Packit Service 54dbc3
	void **p_ptr_array;
Packit Service 54dbc3
	cl_state_t state;
Packit Service 54dbc3
} cl_vector_t;
Packit Service 54dbc3
/*
Packit Service 54dbc3
* FIELDS
Packit Service 54dbc3
*	size
Packit Service 54dbc3
*		 Number of elements successfully initialized in the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	grow_size
Packit Service 54dbc3
*		 Number of elements to allocate when growing.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	capacity
Packit Service 54dbc3
*		 total # of elements allocated.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	element_size
Packit Service 54dbc3
*		 Size of each element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_init
Packit Service 54dbc3
*		 User supplied element initializer.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_dtor
Packit Service 54dbc3
*		 User supplied element destructor.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_copy
Packit Service 54dbc3
*		 Copy operator.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		 User context for callbacks.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	alloc_list
Packit Service 54dbc3
*		 List of allocations.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_ptr_array
Packit Service 54dbc3
*		 Internal array of pointers to elements.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	state
Packit Service 54dbc3
*		State of the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_construct
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_construct
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_construct function constructs a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
void cl_vector_construct(IN cl_vector_t * const p_vector);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure to construct.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	Allows calling cl_vector_destroy without first calling cl_vector_init.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Calling cl_vector_construct is a prerequisite to calling any other
Packit Service 54dbc3
*	vector function except cl_vector_init.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_init, cl_vector_destroy
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_init
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_init
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_init function initializes a vector for use.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
cl_status_t
Packit Service 54dbc3
cl_vector_init(IN cl_vector_t * const p_vector,
Packit Service 54dbc3
	       IN const size_t min_size,
Packit Service 54dbc3
	       IN const size_t grow_size,
Packit Service 54dbc3
	       IN const size_t element_size,
Packit Service 54dbc3
	       IN cl_pfn_vec_init_t pfn_init OPTIONAL,
Packit Service 54dbc3
	       IN cl_pfn_vec_dtor_t pfn_dtor OPTIONAL,
Packit Service 54dbc3
	       IN const void *const context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure to inititalize.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	min_size
Packit Service 54dbc3
*		[in] Initial number of elements.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	grow_size
Packit Service 54dbc3
*		[in] Number of elements to allocate when incrementally growing
Packit Service 54dbc3
*		the vector.  A value of zero disables automatic growth.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	element_size
Packit Service 54dbc3
*		[in] Size of each element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_init
Packit Service 54dbc3
*		[in] Initializer callback to invoke for every new element.
Packit Service 54dbc3
*		See the cl_pfn_vec_init_t function type declaration for details about
Packit Service 54dbc3
*		the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_dtor
Packit Service 54dbc3
*		[in] Destructor callback to invoke for elements being deallocated.
Packit Service 54dbc3
*		See the cl_pfn_vec_dtor_t function type declaration for details about
Packit Service 54dbc3
*		the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Value to pass to the callback functions to provide context.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	CL_SUCCESS if the vector was initialized successfully.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_INSUFFICIENT_MEMORY if the initialization failed.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	cl_status_t value returned by optional initializer function specified by
Packit Service 54dbc3
*	the pfn_init parameter.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	The constructor and initializer functions, if any, are invoked for every
Packit Service 54dbc3
*	new element in the array.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_construct, cl_vector_destroy, cl_vector_set,
Packit Service 54dbc3
*	cl_vector_get, cl_vector_get_ptr, cl_vector_at
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_destroy
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_destroy
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_destroy function destroys a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
void cl_vector_destroy(IN cl_vector_t * const p_vector);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure to destroy.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_destroy frees all memory allocated for the vector. The vector
Packit Service 54dbc3
*	is left initialized to a zero capacity and size.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	This function should only be called after a call to cl_vector_construct
Packit Service 54dbc3
*	or cl_vector_init.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_construct, cl_vector_init
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_get_capacity
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_get_capacity
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_get_capacity function returns the capacity of a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
static inline size_t
Packit Service 54dbc3
cl_vector_get_capacity(IN const cl_vector_t * const p_vector)
Packit Service 54dbc3
{
Packit Service 54dbc3
	CL_ASSERT(p_vector);
Packit Service 54dbc3
	CL_ASSERT(p_vector->state == CL_INITIALIZED);
Packit Service 54dbc3
Packit Service 54dbc3
	return (p_vector->capacity);
Packit Service 54dbc3
}
Packit Service 54dbc3
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure whose capacity to return.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	Capacity, in elements, of the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	The capacity is the number of elements that the vector can store, and
Packit Service 54dbc3
*	can be greater than the number of elements stored. To get the number of
Packit Service 54dbc3
*	elements stored in the vector, use cl_vector_get_size.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_set_capacity, cl_vector_get_size
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_get_size
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_get_size
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_get_size function returns the size of a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
static inline size_t cl_vector_get_size(IN const cl_vector_t * const p_vector)
Packit Service 54dbc3
{
Packit Service 54dbc3
	CL_ASSERT(p_vector);
Packit Service 54dbc3
	CL_ASSERT(p_vector->state == CL_INITIALIZED);
Packit Service 54dbc3
Packit Service 54dbc3
	return (p_vector->size);
Packit Service 54dbc3
}
Packit Service 54dbc3
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure whose size to return.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	Size, in elements, of the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_set_size, cl_vector_get_capacity
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_get_ptr
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_get_ptr
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_get_ptr function returns a pointer to an element
Packit Service 54dbc3
*	stored in a vector at a specified index.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
static inline void *cl_vector_get_ptr(IN const cl_vector_t * const p_vector,
Packit Service 54dbc3
				      IN const size_t index)
Packit Service 54dbc3
{
Packit Service 54dbc3
	CL_ASSERT(p_vector);
Packit Service 54dbc3
	CL_ASSERT(p_vector->state == CL_INITIALIZED);
Packit Service 54dbc3
Packit Service 54dbc3
	return (p_vector->p_ptr_array[index]);
Packit Service 54dbc3
}
Packit Service 54dbc3
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure from which to get a
Packit Service 54dbc3
*		pointer to an element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	index
Packit Service 54dbc3
*		[in] Index of the element.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	Pointer to the element stored at specified index.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_get_ptr provides constant access times regardless of the index.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	cl_vector_get_ptr does not perform boundary checking. Callers are
Packit Service 54dbc3
*	responsible for providing an index that is within the range of the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get, cl_vector_at, cl_vector_set, cl_vector_get_size
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_get
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_get
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_get function copies an element stored in a vector at a
Packit Service 54dbc3
*	specified index.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
static inline void
Packit Service 54dbc3
cl_vector_get(IN const cl_vector_t * const p_vector,
Packit Service 54dbc3
	      IN const size_t index, OUT void *const p_element)
Packit Service 54dbc3
{
Packit Service 54dbc3
	void *p_src;
Packit Service 54dbc3
Packit Service 54dbc3
	CL_ASSERT(p_vector);
Packit Service 54dbc3
	CL_ASSERT(p_vector->state == CL_INITIALIZED);
Packit Service 54dbc3
	CL_ASSERT(p_element);
Packit Service 54dbc3
Packit Service 54dbc3
	/* Get a pointer to the element. */
Packit Service 54dbc3
	p_src = cl_vector_get_ptr(p_vector, index);
Packit Service 54dbc3
	p_vector->pfn_copy(p_src, p_element, p_vector->element_size);
Packit Service 54dbc3
}
Packit Service 54dbc3
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure from which to get a copy of
Packit Service 54dbc3
*		an element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	index
Packit Service 54dbc3
*		[in] Index of the element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[out] Pointer to storage for the element. Contains a copy of the
Packit Service 54dbc3
*		desired element upon successful completion of the call.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_get provides constant time access regardless of the index.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	cl_vector_get does not perform boundary checking on the vector, and
Packit Service 54dbc3
*	callers are responsible for providing an index that is within the range
Packit Service 54dbc3
*	of the vector. To access elements after performing boundary checks,
Packit Service 54dbc3
*	use cl_vector_at.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	The p_element parameter contains a copy of the desired element upon
Packit Service 54dbc3
*	return from this function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get_ptr, cl_vector_at
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_at
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_at
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_at function copies an element stored in a vector at a
Packit Service 54dbc3
*	specified index, performing boundary checks.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
cl_status_t
Packit Service 54dbc3
cl_vector_at(IN const cl_vector_t * const p_vector,
Packit Service 54dbc3
	     IN const size_t index, OUT void *const p_element);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure from which to get a copy of
Packit Service 54dbc3
*		an element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	index
Packit Service 54dbc3
*		[in] Index of the element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[out] Pointer to storage for the element. Contains a copy of the
Packit Service 54dbc3
*		desired element upon successful completion of the call.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	CL_SUCCESS if an element was found at the specified index.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_INVALID_SETTING if the index was out of range.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_at provides constant time access regardless of the index, and
Packit Service 54dbc3
*	performs boundary checking on the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Upon success, the p_element parameter contains a copy of the desired element.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get, cl_vector_get_ptr
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_set
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_set
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_set function sets the element at the specified index.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
cl_status_t
Packit Service 54dbc3
cl_vector_set(IN cl_vector_t * const p_vector,
Packit Service 54dbc3
	      IN const size_t index, IN void *const p_element);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure into which to store
Packit Service 54dbc3
*		an element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	index
Packit Service 54dbc3
*		[in] Index of the element.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	p_element
Packit Service 54dbc3
*		[in] Pointer to an element to store in the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	CL_SUCCESS if the element was successfully set.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_INSUFFICIENT_MEMORY if the vector could not be resized to accommodate
Packit Service 54dbc3
*	the new element.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_set grows the vector as needed to accommodate the new element,
Packit Service 54dbc3
*	unless the grow_size parameter passed into the cl_vector_init function
Packit Service 54dbc3
*	was zero.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_set_capacity
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_set_capacity
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_set_capacity function reserves memory in a vector for a
Packit Service 54dbc3
*	specified number of elements.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
cl_status_t
Packit Service 54dbc3
cl_vector_set_capacity(IN cl_vector_t * const p_vector,
Packit Service 54dbc3
		       IN const size_t new_capacity);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure whose capacity to set.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	new_capacity
Packit Service 54dbc3
*		[in] Total number of elements for which the vector should
Packit Service 54dbc3
*		allocate memory.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	CL_SUCCESS if the capacity was successfully set.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_INSUFFICIENT_MEMORY if there was not enough memory to satisfy the
Packit Service 54dbc3
*	operation. The vector is left unchanged.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_set_capacity increases the capacity of the vector. It does
Packit Service 54dbc3
*	not change the size of the vector. If the requested capacity is less
Packit Service 54dbc3
*	than the current capacity, the vector is left unchanged.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get_capacity, cl_vector_set_size,
Packit Service 54dbc3
*	cl_vector_set_min_size
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_set_size
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_set_size
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_set_size function resizes a vector, either increasing or
Packit Service 54dbc3
*	decreasing its size.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
cl_status_t
Packit Service 54dbc3
cl_vector_set_size(IN cl_vector_t * const p_vector, IN const size_t size);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure whose size to set.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	size
Packit Service 54dbc3
*		[in] Number of elements desired in the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	CL_SUCCESS if the size of the vector was set successfully.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_INSUFFICIENT_MEMORY if there was not enough memory to complete the
Packit Service 54dbc3
*	operation. The vector is left unchanged.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_set_size sets the vector to the specified size. If size is
Packit Service 54dbc3
*	smaller than the current size of the vector, the size is reduced.
Packit Service 54dbc3
*	The destructor function, if any, will be invoked for all elements that
Packit Service 54dbc3
*	are above size. Likewise, the constructor and initializer, if any, will
Packit Service 54dbc3
*	be invoked for all new elements.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	This function can only fail if size is larger than the current capacity.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get_size, cl_vector_set_min_size,
Packit Service 54dbc3
*	cl_vector_set_capacity
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_set_min_size
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_set_min_size
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_set_min_size function resizes a vector to a specified size
Packit Service 54dbc3
*	if the vector is smaller than the specified size.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
cl_status_t
Packit Service 54dbc3
cl_vector_set_min_size(IN cl_vector_t * const p_vector,
Packit Service 54dbc3
		       IN const size_t min_size);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure whose minimum size to set.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	min_size
Packit Service 54dbc3
*		[in] Minimum number of elements that the vector should contain.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	CL_SUCCESS if the vector size is greater than or equal to min_size.  This
Packit Service 54dbc3
*	could indicate that the vector's capacity was increased to min_size or
Packit Service 54dbc3
*	that the vector was already of sufficient size.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	CL_INSUFFICIENT_MEMORY if there was not enough memory to resize the vector.
Packit Service 54dbc3
*	The vector is left unchanged.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	If min_size is smaller than the current size of the vector, the vector is
Packit Service 54dbc3
*	unchanged. The vector is unchanged if the size could not be changed due
Packit Service 54dbc3
*	to insufficient memory being available to perform the operation.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_get_size, cl_vector_set_size, cl_vector_set_capacity
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_apply_func
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_apply_func
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_apply_func function invokes a specified function for every
Packit Service 54dbc3
*	element in a vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
void
Packit Service 54dbc3
cl_vector_apply_func(IN const cl_vector_t * const p_vector,
Packit Service 54dbc3
		     IN cl_pfn_vec_apply_t pfn_callback,
Packit Service 54dbc3
		     IN const void *const context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure whose elements to iterate.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_callback
Packit Service 54dbc3
*		[in] Function invoked for every element in the array.
Packit Service 54dbc3
*		See the cl_pfn_vec_apply_t function type declaration for details
Packit Service 54dbc3
*		about the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Value to pass to the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUE
Packit Service 54dbc3
*	This function does not return a value.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_apply_func invokes the specified function for every element
Packit Service 54dbc3
*	in the vector, starting from the beginning of the vector.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_find_from_start, cl_vector_find_from_end,
Packit Service 54dbc3
*	cl_pfn_vec_apply_t
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_find_from_start
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_find_from_start
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_find_from_start function uses a specified function to
Packit Service 54dbc3
*	search for elements in a vector starting from the lowest index.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
size_t
Packit Service 54dbc3
cl_vector_find_from_start(IN const cl_vector_t * const p_vector,
Packit Service 54dbc3
			  IN cl_pfn_vec_find_t pfn_callback,
Packit Service 54dbc3
			  IN const void *const context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure to inititalize.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_callback
Packit Service 54dbc3
*		[in] Function invoked to determine if a match was found.
Packit Service 54dbc3
*		See the cl_pfn_vec_find_t function type declaration for details
Packit Service 54dbc3
*		about the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Value to pass to the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	Index of the element, if found.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Size of the vector if the element was not found.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_find_from_start does not remove the found element from
Packit Service 54dbc3
*	the vector. The index of the element is returned when the function
Packit Service 54dbc3
*	provided by the pfn_callback parameter returns CL_SUCCESS.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_find_from_end, cl_vector_apply_func, cl_pfn_vec_find_t
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
/****f* Component Library: Vector/cl_vector_find_from_end
Packit Service 54dbc3
* NAME
Packit Service 54dbc3
*	cl_vector_find_from_end
Packit Service 54dbc3
*
Packit Service 54dbc3
* DESCRIPTION
Packit Service 54dbc3
*	The cl_vector_find_from_end function uses a specified function to search
Packit Service 54dbc3
*	for elements in a vector starting from the highest index.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SYNOPSIS
Packit Service 54dbc3
*/
Packit Service 54dbc3
size_t
Packit Service 54dbc3
cl_vector_find_from_end(IN const cl_vector_t * const p_vector,
Packit Service 54dbc3
			IN cl_pfn_vec_find_t pfn_callback,
Packit Service 54dbc3
			IN const void *const context);
Packit Service 54dbc3
/*
Packit Service 54dbc3
* PARAMETERS
Packit Service 54dbc3
*	p_vector
Packit Service 54dbc3
*		[in] Pointer to a cl_vector_t structure to inititalize.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	pfn_callback
Packit Service 54dbc3
*		[in] Function invoked to determine if a match was found.
Packit Service 54dbc3
*		See the cl_pfn_vec_find_t function type declaration for details
Packit Service 54dbc3
*		about the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	context
Packit Service 54dbc3
*		[in] Value to pass to the callback function.
Packit Service 54dbc3
*
Packit Service 54dbc3
* RETURN VALUES
Packit Service 54dbc3
*	Index of the element, if found.
Packit Service 54dbc3
*
Packit Service 54dbc3
*	Size of the vector if the element was not found.
Packit Service 54dbc3
*
Packit Service 54dbc3
* NOTES
Packit Service 54dbc3
*	cl_vector_find_from_end does not remove the found element from
Packit Service 54dbc3
*	the vector. The index of the element is returned when the function
Packit Service 54dbc3
*	provided by the pfn_callback parameter returns CL_SUCCESS.
Packit Service 54dbc3
*
Packit Service 54dbc3
* SEE ALSO
Packit Service 54dbc3
*	Vector, cl_vector_find_from_start, cl_vector_apply_func,
Packit Service 54dbc3
*	cl_pfn_vec_find_t
Packit Service 54dbc3
*********/
Packit Service 54dbc3
Packit Service 54dbc3
END_C_DECLS
Packit Service 54dbc3
#endif				/* _CL_VECTOR_H_ */