2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * A pointer array which intelligently expands its capacity ad needed.
31 typedef struct Array Array
;
33 /** Constructs a new array. Returns NULL if we ran out of memory. */
36 /** Frees an array. Does not free elements themselves. */
37 void arrayFree(Array
* array
);
39 /** Adds a pointer. Returns 0 is successful, < 0 otherwise. */
40 int arrayAdd(Array
* array
, void* pointer
);
42 /** Gets the pointer at the specified index. */
43 void* arrayGet(Array
* array
, int index
);
45 /** Removes the pointer at the given index and returns it. */
46 void* arrayRemove(Array
* array
, int index
);
48 /** Sets pointer at the given index. Returns old pointer. */
49 void* arraySet(Array
* array
, int index
, void* pointer
);
51 /** Sets the array size. Sets new pointers to NULL. Returns 0 if successful, < 0 otherwise . */
52 int arraySetSize(Array
* array
, int size
);
54 /** Returns the size of the given array. */
55 int arraySize(Array
* array
);
58 * Returns a pointer to a C-style array which will be valid until this array
61 const void** arrayUnwrap(Array
* array
);
67 #endif /* __ARRAY_H */