2008-03-25 19:49:32 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* $Id$
|
|
|
|
*
|
2008-01-01 17:20:20 +00:00
|
|
|
* This file Copyright (C) 2007-2008 Charles Kerr <charles@rebelbase.com>
|
2007-08-14 20:45:23 +00:00
|
|
|
*
|
2008-03-25 19:49:32 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2007-08-18 17:05:51 +00:00
|
|
|
*
|
2008-03-25 19:49:32 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*****************************************************************************/
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-11-24 20:17:36 +00:00
|
|
|
#ifndef __TRANSMISSION__
|
|
|
|
#error only libtransmission should #include this header.
|
|
|
|
#endif
|
|
|
|
|
2008-03-25 19:49:32 +00:00
|
|
|
#ifndef _TR_PTR_ARRAY_H_
|
|
|
|
#define _TR_PTR_ARRAY_H_
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A simple pointer array that resizes itself dynamically.
|
|
|
|
*/
|
2007-09-20 16:32:01 +00:00
|
|
|
typedef struct tr_ptrArray tr_ptrArray;
|
2007-08-14 20:45:23 +00:00
|
|
|
|
2008-09-23 19:11:04 +00:00
|
|
|
typedef void ( *PtrArrayForeachFunc )( void * );
|
|
|
|
|
|
|
|
tr_ptrArray * tr_ptrArrayNew( void );
|
|
|
|
|
|
|
|
tr_ptrArray * tr_ptrArrayDup( tr_ptrArray* );
|
|
|
|
|
2008-11-23 16:30:09 +00:00
|
|
|
void tr_ptrArrayForeach( tr_ptrArray * array,
|
|
|
|
PtrArrayForeachFunc func );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void tr_ptrArrayFree( tr_ptrArray * array,
|
|
|
|
PtrArrayForeachFunc func );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void* tr_ptrArrayNth( tr_ptrArray * array,
|
|
|
|
int nth );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void* tr_ptrArrayBack( tr_ptrArray * array );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void** tr_ptrArrayPeek( tr_ptrArray * array,
|
|
|
|
int * size );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void** tr_ptrArrayBase( tr_ptrArray * array );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void tr_ptrArrayClear( tr_ptrArray * array );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
int tr_ptrArrayInsert( tr_ptrArray * array,
|
|
|
|
void * insertMe,
|
|
|
|
int pos );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
int tr_ptrArrayAppend( tr_ptrArray * array,
|
|
|
|
void * appendMe );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void* tr_ptrArrayPop( tr_ptrArray * array );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void tr_ptrArrayErase( tr_ptrArray * array,
|
|
|
|
int begin,
|
|
|
|
int end );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
|
|
|
int tr_ptrArraySize( const tr_ptrArray* );
|
|
|
|
|
|
|
|
int tr_ptrArrayEmpty( const tr_ptrArray* );
|
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
int tr_ptrArrayInsertSorted( tr_ptrArray * array,
|
|
|
|
void * value,
|
|
|
|
int compare(const void*, const void*) );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void* tr_ptrArrayRemoveSorted( tr_ptrArray * array,
|
|
|
|
void * value,
|
|
|
|
int compare(const void*, const void*) );
|
2008-09-23 19:11:04 +00:00
|
|
|
|
2008-10-25 02:15:37 +00:00
|
|
|
void* tr_ptrArrayFindSorted( tr_ptrArray * array,
|
|
|
|
const void * key,
|
|
|
|
int compare(const void*, const void*) );
|
2007-08-14 20:45:23 +00:00
|
|
|
|
|
|
|
#endif
|