Home | History | Annotate | Download | only in src
      1 /*---------------------------------------------------------------------------*
      2  *  HashMap.c  *
      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 #include "HashMap.h"
     21 #include "HashMapImpl.h"
     22 #include "pmemory.h"
     23 #include <string.h>
     24 
     25 ESR_ReturnCode HashMapPut(HashMap* self, const LCHAR* key, void* value)
     26 {
     27   if (self == NULL)
     28     return ESR_INVALID_ARGUMENT;
     29   return self->put(self, key, value);
     30 }
     31 
     32 ESR_ReturnCode HashMapRemove(HashMap* self, const LCHAR* key)
     33 {
     34   if (self == NULL)
     35     return ESR_INVALID_ARGUMENT;
     36   return self->remove(self, key);
     37 }
     38 
     39 ESR_ReturnCode HashMapRemoveAndFree(HashMap* self, const LCHAR* key)
     40 {
     41   if (self == NULL)
     42     return ESR_INVALID_ARGUMENT;
     43   return self->removeAndFree(self, key);
     44 }
     45 
     46 ESR_ReturnCode HashMapRemoveAtIndex(HashMap* self, const size_t index)
     47 {
     48   if (self == NULL)
     49     return ESR_INVALID_ARGUMENT;
     50   return self->removeAtIndex(self, index);
     51 }
     52 
     53 ESR_ReturnCode HashMapRemoveAll(HashMap* self)
     54 {
     55   if (self == NULL)
     56     return ESR_INVALID_ARGUMENT;
     57   return self->removeAll(self);
     58 }
     59 
     60 ESR_ReturnCode HashMapRemoveAndFreeAll(HashMap* self)
     61 {
     62   if (self == NULL)
     63     return ESR_INVALID_ARGUMENT;
     64   return self->removeAndFreeAll(self);
     65 }
     66 
     67 ESR_ReturnCode HashMapContainsKey(HashMap* self, const LCHAR* key, ESR_BOOL* exists)
     68 {
     69   if (self == NULL)
     70     return ESR_INVALID_ARGUMENT;
     71   return self->containsKey(self, key, exists);
     72 }
     73 
     74 ESR_ReturnCode HashMapGetSize(HashMap* self, size_t* size)
     75 {
     76   if (self == NULL)
     77     return ESR_INVALID_ARGUMENT;
     78   return self->getSize(self, size);
     79 }
     80 
     81 ESR_ReturnCode HashMapGet(HashMap* self, const LCHAR* key, void** value)
     82 {
     83   if (self == NULL)
     84     return ESR_INVALID_ARGUMENT;
     85   return self->get(self, key, value);
     86 }
     87 
     88 ESR_ReturnCode HashMapGetKeyAtIndex(HashMap* self, const size_t index, LCHAR** key)
     89 {
     90   if (self == NULL)
     91     return ESR_INVALID_ARGUMENT;
     92   return self->getKeyAtIndex(self, index, key);
     93 }
     94 
     95 ESR_ReturnCode HashMapGetValueAtIndex(HashMap* self, const size_t index, void** value)
     96 {
     97   if (self == NULL)
     98     return ESR_INVALID_ARGUMENT;
     99   return self->getValueAtIndex(self, index, value);
    100 }
    101 
    102 ESR_ReturnCode HashMapDestroy(HashMap* self)
    103 {
    104   if (self == NULL)
    105     return ESR_INVALID_ARGUMENT;
    106   return self->destroy(self);
    107 }
    108