Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  Int8ArrayList.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 __INT8ARRAYLIST_H
     21 #define __INT8ARRAYLIST_H
     22 
     23 
     24 
     25 #include "ESR_ReturnCode.h"
     26 #include "ESR_SharedPrefix.h"
     27 #include "ptypes.h"
     28 #include <stdlib.h>
     29 
     30 /**
     31  * @addtogroup Int8ArrayListModule Int8ArrayList API functions
     32  * List of Int8 elements.
     33  *
     34  * @{
     35  */
     36 
     37 /**
     38  * List of elements.
     39  */
     40 typedef struct Int8ArrayList_t
     41 {
     42   /**
     43    * Adds element to list.
     44    *
     45    * @param self Int8ArrayList handle
     46    * @param element Element to be added
     47    */
     48   ESR_ReturnCode(*add)(struct Int8ArrayList_t* self, asr_int8_t element);
     49 
     50   /**
     51   * Removes element from list.
     52   *
     53   * @param self Int8ArrayList handle
     54   * @param element Element to be removed
     55   */
     56   ESR_ReturnCode(*remove)(struct Int8ArrayList_t* self, asr_int8_t element);
     57 
     58   /**
     59   * Removes all elements from list.
     60   *
     61   * @param self Int8ArrayList handle
     62   */
     63   ESR_ReturnCode(*removeAll)(struct Int8ArrayList_t* self);
     64 
     65   /**
     66   * Indicates if element is contained within the list.
     67   *
     68   * @param self Int8ArrayList handle
     69   * @param element Element to check for
     70   * @param exists True if element was found
     71   */
     72   ESR_ReturnCode(*contains)(struct Int8ArrayList_t* self, asr_int8_t element, ESR_BOOL* exists);
     73 
     74   /**
     75   * Returns array size.
     76   *
     77   * @param self Int8ArrayList handle
     78   * @param size Returned size
     79   */
     80   ESR_ReturnCode(*getSize)(struct Int8ArrayList_t* self, size_t* size);
     81 
     82   /**
     83   * Returns the element at the specified index.
     84   *
     85   * @param self Int8ArrayList handle
     86   * @param index Element index
     87   * @param element Element being returned
     88   */
     89   ESR_ReturnCode(*get)(struct Int8ArrayList_t* self, size_t index, asr_int8_t* element);
     90 
     91   /**
     92   * Sets the element at the specified index.
     93   *
     94   * NOTE: Does *not* deallocate the element being overwritten.
     95   * @param self Int8ArrayList handle
     96   * @param index Element index
     97   * @param element Element's new value
     98   */
     99   ESR_ReturnCode(*set)(struct Int8ArrayList_t* self, size_t index, asr_int8_t element);
    100 
    101   /**
    102   * Returns a clone of the Int8ArrayList.
    103   * @param self Int8ArrayList handle
    104    * @param clone [out] Clone of the Int8ArrayList (created externally, populated
    105    *                    internally)
    106   */
    107   ESR_ReturnCode(*clone)(struct Int8ArrayList_t* self, struct Int8ArrayList_t* clone);
    108 
    109   /**
    110    * Converts the Int8ArrayList to a static array.
    111    * The use of the Int8ArrayList handle is undefined past this point.
    112    *
    113    * @param self Int8ArrayList handle
    114    * @param newArray Pointer to resulting array
    115    */
    116   ESR_ReturnCode(*toStaticArray)(struct Int8ArrayList_t* self, asr_int8_t** newArray);
    117 
    118   /**
    119   * Destroys the Int8ArrayList.
    120   * @param self Int8ArrayList handle
    121   */
    122   ESR_ReturnCode(*destroy)(struct Int8ArrayList_t* self);
    123 }
    124 Int8ArrayList;
    125 
    126 /**
    127  * Creates a new Int8ArrayList.
    128  *
    129  * @param self ArrayList handle
    130  */
    131 ESR_SHARED_API ESR_ReturnCode Int8ArrayListCreate(Int8ArrayList** self);
    132 
    133 /**
    134  * Creates a new Int8ArrayList from the supplied static array.
    135  * The static array may not be used past this point.
    136  *
    137  * @param value Initial value
    138  * @param self Int8ArrayList handle
    139  */
    140 ESR_SHARED_API ESR_ReturnCode Int8ArrayListImport(asr_int8_t* value, Int8ArrayList** self);
    141 
    142 /**
    143  * Adds element to list.
    144  *
    145  * @param self Int8ArrayList handle
    146  * @param element Element to be added
    147  */
    148 ESR_SHARED_API ESR_ReturnCode Int8ArrayListAdd(Int8ArrayList* self, asr_int8_t element);
    149 
    150 /**
    151  * Removes element from list.
    152  *
    153  * @param self Int8ArrayList handle
    154  * @param element Element to be removed
    155  */
    156 ESR_SHARED_API ESR_ReturnCode Int8ArrayListRemove(Int8ArrayList* self, asr_int8_t element);
    157 
    158 /**
    159  * Removes all elements from list.
    160  *
    161  * @param self Int8ArrayList handle
    162  */
    163 ESR_SHARED_API ESR_ReturnCode Int8ArrayListRemoveAll(Int8ArrayList* self);
    164 
    165 /**
    166  * Indicates if element is contained within the list.
    167  *
    168  * @param self Int8ArrayList handle
    169  * @param element Element to check for
    170  * @param exists True if element was found
    171  */
    172 ESR_SHARED_API ESR_ReturnCode Int8ArrayListContains(Int8ArrayList* self, asr_int8_t element, ESR_BOOL* exists);
    173 
    174 /**
    175  * Returns array size.
    176  *
    177  * @param self Int8ArrayList handle
    178  * @param size Returned size
    179  */
    180 ESR_SHARED_API ESR_ReturnCode Int8ArrayListGetSize(Int8ArrayList* self, size_t* size);
    181 
    182 /**
    183  * Returns the element at the specified index.
    184  *
    185  * @param self Int8ArrayList handle
    186  * @param index Element index
    187  * @param element Element being returned
    188  */
    189 ESR_SHARED_API ESR_ReturnCode Int8ArrayListGet(Int8ArrayList* self, size_t index, asr_int8_t* element);
    190 
    191 /**
    192  * Sets the element at the specified index.
    193  *
    194  * NOTE: Does *not* deallocate the element being overwritten.
    195  * @param self Int8ArrayList handle
    196  * @param index Element index
    197  * @param element Element's new value
    198  */
    199 ESR_SHARED_API ESR_ReturnCode Int8ArrayListSet(Int8ArrayList* self, size_t index, asr_int8_t element);
    200 
    201 /**
    202  * Converts the Int8ArrayList to a static array.
    203  * The Int8ArrayList handle may not be used past this point.
    204  *
    205  * @param self Int8ArrayList handle
    206  * @param newArray Pointer to resulting array
    207  */
    208 ESR_SHARED_API ESR_ReturnCode Int8ArrayListToStaticArray(Int8ArrayList* self, asr_int8_t** newArray);
    209 
    210 /**
    211  * Returns a clone of the Int8ArrayList.
    212  * @param self Int8ArrayList handle
    213  * @param clone [out] Clone of the Int8ArrayList (created externally, populated
    214  *                    internally)
    215  */
    216 ESR_SHARED_API ESR_ReturnCode Int8ArrayListClone(Int8ArrayList* self, Int8ArrayList* clone);
    217 
    218 /**
    219  * Destroys an Int8ArrayList.
    220  *
    221  * @param self Int8ArrayList handle
    222  */
    223 ESR_SHARED_API ESR_ReturnCode Int8ArrayListDestroy(Int8ArrayList* self);
    224 
    225 /**
    226  * @}
    227  */
    228 
    229 
    230 #endif /* __INT8ARRAYLIST_H */
    231