1/*---------------------------------------------------------------------------* 2 * ArrayListImpl.h * 3 * * 4 * Copyright 2007, 2008 Nuance Communciations, Inc. * 5 * * 6 * Licensed under the Apache License, Version 2.0 (the 'License'); * 7 * you may not use this file except in compliance with the License. * 8 * * 9 * You may obtain a copy of the License at * 10 * http://www.apache.org/licenses/LICENSE-2.0 * 11 * * 12 * Unless required by applicable law or agreed to in writing, software * 13 * distributed under the License is distributed on an 'AS IS' BASIS, * 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * 15 * See the License for the specific language governing permissions and * 16 * limitations under the License. * 17 * * 18 *---------------------------------------------------------------------------*/ 19 20#ifndef __ARRAYLISTIMPL_H 21#define __ARRAYLISTIMPL_H 22 23 24 25#include "ESR_ReturnCode.h" 26#include "PortPrefix.h" 27 28/** 29 * ArrayList implementation. 30 */ 31typedef struct ArrayListImpl_t 32{ 33 /** 34 * Interface functions that must be implemented. 35 */ 36 ArrayList Interface; 37 38 /** 39 * ArrayList contents. 40 * 41 * Represents an array of void* elements. An element having a value of NULL denotes an 42 * empty slot. 43 */ 44 void** contents; 45 46 /** 47 * number element in the array. 48 */ 49 size_t size; 50 51 /** 52 * Actual capacity of the array. 53 */ 54 size_t capacity; 55 56 /** 57 * Min capacity of the array. 58 **/ 59 size_t minCapacity; 60 61} 62ArrayListImpl; 63 64 65/** 66 * Default implementation. 67 */ 68PORTABLE_API ESR_ReturnCode ArrayList_Add(ArrayList* self, void* element); 69 70/** 71 * Default implementation. 72 */ 73PORTABLE_API ESR_ReturnCode ArrayList_InsertAt(ArrayList* self, size_t index, void* element); 74 75/** 76 * Default implementation. 77 */ 78PORTABLE_API ESR_ReturnCode ArrayList_Remove(ArrayList* self, const void* element); 79 80/** 81 * Default implementation. 82 */ 83PORTABLE_API ESR_ReturnCode ArrayList_RemoveAtIndex(ArrayList* self, size_t index); 84 85/** 86 * Default implementation. 87 */ 88PORTABLE_API ESR_ReturnCode ArrayList_RemoveAll(ArrayList* self); 89 90/** 91 * Default implementation. 92 */ 93PORTABLE_API ESR_ReturnCode ArrayList_Contains(ArrayList* self, const void* element, ESR_BOOL* exists); 94 95/** 96 * Default implementation. 97 */ 98PORTABLE_API ESR_ReturnCode ArrayList_Get(ArrayList* self, size_t index, void** element); 99 100/** 101 * Default implementation. 102 */ 103PORTABLE_API ESR_ReturnCode ArrayList_Set(ArrayList* self, size_t index, void* element); 104 105/** 106 * Default implementation. 107 */ 108PORTABLE_API ESR_ReturnCode ArrayList_GetSize(ArrayList* self, size_t* size); 109 110/** 111 * Default implementation. 112 */ 113PORTABLE_API ESR_ReturnCode ArrayList_Clone(ArrayList* self, ArrayList* clone); 114 115/** 116 * Default implementation. 117 */ 118PORTABLE_API ESR_ReturnCode ArrayList_Destroy(ArrayList* self); 119 120#endif /* __ARRAYLIST_H */ 121