First public contribution.
2 * Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Dynamic pointer array
18 #ifndef __M3G_ARRAY_H__
19 #define __M3G_ARRAY_H__
24 * \brief Dynamic pointer array
29 * \brief Dynamic array structure
31 * Prior to using an array, the structure must be initialized by
32 * either calling \c m3gInitArray or explicitly clearing the structure
37 M3Gsizei size, capacity;
41 /*----------------------------------------------------------------------
43 *--------------------------------------------------------------------*/
45 static M3Gint m3gArrayAppend (PointerArray *array,
48 static void m3gArrayDelete (PointerArray *array, M3Gint idx);
49 static M3Gint m3gArrayInsert (PointerArray *array,
53 static M3Gint m3gArrayFind (const PointerArray *array, void *item);
54 #if 0 /* currently disabled, but available if needed */
55 static M3Gbool m3gArrayRemove (PointerArray *array, void *item);
57 static M3Gsizei m3gArraySize (const PointerArray *array);
58 static void m3gClearArray (PointerArray *array);
59 static void m3gDestroyArray (PointerArray *array, Interface *m3g);
60 static M3Gbool m3gEnsureArrayCapacity(PointerArray *array,
63 static void* m3gGetArrayElement(const PointerArray *array, M3Gint idx);
64 static void m3gInitArray (PointerArray *array);
65 #if defined(M3G_NATIVE_LOADER) /* currently only used in loader */
66 static void m3gSetArrayElement(PointerArray *array,
70 #if 0 /* currently unused, but available here */
71 static M3Gbool m3gTrimArray (PointerArray *array, Interface *m3g);
74 /*----------------------------------------------------------------------
76 *--------------------------------------------------------------------*/
80 * \brief Returns the number of elements in the array
82 static M3G_INLINE M3Gsizei m3gArraySize(const PointerArray *array)
84 M3G_ASSERT_PTR(array);
85 M3G_ASSERT(array->size <= array->capacity);
91 * \brief Returns the array element at \c index
93 static M3G_INLINE void *m3gGetArrayElement(const PointerArray *array,
96 M3G_ASSERT_PTR(array);
97 M3G_ASSERT(idx >= 0 && idx < array->size);
98 return array->items[idx];
101 #if defined(M3G_NATIVE_LOADER) /* currently only used in loader */
104 * \brief Sets the value of the array element at \c index
106 static M3G_INLINE void m3gSetArrayElement(PointerArray *array,
110 M3G_ASSERT_PTR(array);
111 M3G_ASSERT(idx >= 0 && idx < array->size);
112 array->items[idx] = item;
116 #endif /*__M3G_ARRAY_H__*/