coan 4.2.4
|
00001 #ifndef PTR_VECTOR_H 00002 #define PTR_VECTOR_H 00003 00004 /*************************************************************************** 00005 * Copyright (C) 2004, 2006 Symbian Software Ltd. * 00006 * All rights reserved. * 00007 * Copyright (C) 2007-2011 Mike Kinghan, imk@strudl.org * 00008 * All rights reserved. * 00009 * * 00010 * Contributed originally by Mike Kinghan, imk@strudl.org * 00011 * * 00012 * Redistribution and use in source and binary forms, with or without * 00013 * modification, are permitted provided that the following conditions * 00014 * are met: * 00015 * * 00016 * Redistributions of source code must retain the above copyright * 00017 * notice, this list of conditions and the following disclaimer. * 00018 * * 00019 * Redistributions in binary form must reproduce the above copyright * 00020 * notice, this list of conditions and the following disclaimer in the * 00021 * documentation and/or other materials provided with the distribution. * 00022 * * 00023 * Neither the name of Symbian Software Ltd. nor the names of its * 00024 * contributors may be used to endorse or promote products derived from * 00025 * this software without specific prior written permission. * 00026 * * 00027 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * 00028 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * 00029 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * 00030 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * 00031 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * 00032 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * 00033 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS * 00034 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * 00035 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,* 00036 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF * 00037 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * 00038 * DAMAGE. * 00039 * * 00040 **************************************************************************/ 00041 #include "bool.h" 00042 #include <stddef.h> 00043 00044 00052 00054 typedef ptrdiff_t locator_t; 00055 00057 typedef struct ptr_vector * ptr_vector_h; 00058 00060 typedef struct ptr_vector const * ptr_vector_const_h; 00061 00063 typedef void (*dtor_t)(void *); 00064 00066 typedef void * (*cloner_t)(void const *); 00067 00078 typedef int (*comparator_t)(void const *obj, void const *key, locator_t keylen); 00079 00089 extern ptr_vector_h 00090 ptr_vector_new(dtor_t dtor, cloner_t cloner); 00091 00101 extern void 00102 ptr_vector_dispose(ptr_vector_h pv); 00103 00117 extern void 00118 ptr_vector_drop(ptr_vector_h pv); 00119 00120 00125 extern ptr_vector_h 00126 ptr_vector_copy(ptr_vector_const_h src); 00127 00129 extern void 00130 ptr_vector_swap(ptr_vector_h lhs, ptr_vector_h rhs); 00131 00136 extern void 00137 ptr_vector_assign(ptr_vector_h dest, ptr_vector_const_h src); 00138 00151 extern void 00152 ptr_vector_insert(ptr_vector_h pv, size_t pos, void const *ptr); 00153 00163 extern bool 00164 ptr_vector_delete(ptr_vector_h pv, size_t pos); 00165 00173 extern void 00174 ptr_vector_append(ptr_vector_h pv, void *ptr); 00175 00178 extern dtor_t 00179 ptr_vector_dtor(ptr_vector_const_h pv); 00180 00183 extern cloner_t 00184 ptr_vector_cloner(ptr_vector_const_h pv); 00185 00190 extern size_t 00191 ptr_vector_count(ptr_vector_const_h pv); 00192 00202 extern bool 00203 ptr_vector_equal( ptr_vector_const_h lhs, 00204 ptr_vector_const_h rhs, 00205 comparator_t compare); 00206 00212 extern void ** 00213 ptr_vector_begin(ptr_vector_h pv); 00214 00220 extern void const ** 00221 ptr_vector_begin_const(ptr_vector_const_h pv); 00222 00228 extern void ** 00229 ptr_vector_end(ptr_vector_h pv); 00230 00236 extern void const ** 00237 ptr_vector_end_const(ptr_vector_const_h pv); 00238 00239 00246 extern void * 00247 ptr_vector_at(ptr_vector_h pv, size_t pos); 00248 00255 extern void const * 00256 ptr_vector_at_const(ptr_vector_const_h pv, size_t pos); 00257 00271 extern locator_t 00272 ptr_vector_search( ptr_vector_const_h pv, 00273 void const *key, locator_t keylen, comparator_t compare, 00274 bool ordered); 00275 00278 #endif /* EOF*/