Coconut Framework  beta
Classes | Macros | Typedefs | Functions
CNDictionary.h File Reference

Define CNDictionary data structure. More...

#include "CNForwarders.h"
#include "CNFixedString.h"
#include "CNArray.h"

Go to the source code of this file.


struct  CNDictionary
 Dictionary of pointer. More...


#define CNHashTableSizeOfDictionary   64


typedef void(* CNReleaseDictionaryItemFuncRef )(void *item, struct CNResource *resource)
typedef CNBoolean(* CNVisitElementOfDictionaryFuncRef )(const struct CNFixedString *key, void *src, void *info)


void CNInitDictionary (struct CNDictionary *dst, CNReleaseDictionaryItemFuncRef func, struct CNResource *resource)
 Initialize CNDictionary. More...
void CNDestroyDictionary (struct CNDictionary *dst)
 Deallocate CNDictionary. More...
static size_t CNCountOfDictionary (const struct CNDictionary *src)
 Number of items in dictionary. More...
static struct CNResource * CNResourceOfDictionary (struct CNDictionary *src)
 Get resource fot the dictionary. More...
void * CNSearchDataInDictionary (const struct CNDictionary *dict, const struct CNFixedString *key)
 Search data in data dictionary. More...
void CNSetDataToDictionary (struct CNDictionary *dict, const struct CNFixedString *key, void *value)
 Set data for key to CNDictionary. More...
CNBoolean CNVisitElementOfDictionary (const struct CNDictionary *src, CNVisitElementOfDictionaryFuncRef visitfunc, void *info)
 Visit all elements in the dictionary. More...

Detailed Description

Define CNDictionary data structure.

Copyright (C) 2012 Steel Wheels Project

Macro Definition Documentation

#define CNHashTableSizeOfDictionary   64

Max hash table size of CNDictionary

Typedef Documentation

typedef void(* CNReleaseDictionaryItemFuncRef)(void *item, struct CNResource *resource)

Function to destroy the item in CNDictionary

typedef CNBoolean(* CNVisitElementOfDictionaryFuncRef)(const struct CNFixedString *key, void *src, void *info)

The function to visit the element in CNDictionary

Function Documentation

void CNInitDictionary ( struct CNDictionary dst,
CNReleaseDictionaryItemFuncRef  func,
struct CNResource *  resource 

Initialize CNDictionary.

dstDestination dictionary
funcFunction to release dictionary item
resourceResource to allocate dictionary
void CNDestroyDictionary ( struct CNDictionary dst)

Deallocate CNDictionary.

dstDestination dictionary

Referenced by CNDestroyObjectDictionary().

static size_t CNCountOfDictionary ( const struct CNDictionary src)

Number of items in dictionary.

Number of items
srcSource dictionary

References CNDictionary::itemCount.

Referenced by CNCountOfObjectDictionary().

static struct CNResource* CNResourceOfDictionary ( struct CNDictionary src)

Get resource fot the dictionary.

Resource of this dictionary
srcSource dictionary

References CNDictionary::resource.

Referenced by CNResourceOfObjectDictionary().

void* CNSearchDataInDictionary ( const struct CNDictionary dict,
const struct CNFixedString key 

Search data in data dictionary.

Return values
objMatched data
NULLNo matched data
dictSource dictionary
keyKey string

Referenced by CNSearchObjectInDictionary().

void CNSetDataToDictionary ( struct CNDictionary dict,
const struct CNFixedString key,
void *  value 

Set data for key to CNDictionary.

dictDestination dictionary
keyKey string

Referenced by CNSetObjectToDictionary().

CNBoolean CNVisitElementOfDictionary ( const struct CNDictionary src,
CNVisitElementOfDictionaryFuncRef  visitfunc,
void *  info 

Visit all elements in the dictionary.

Return values
TRUEAll elements are visited
FALSEAll elements are NOT visited
srcSource array
visitfuncFunction which is called foreach elements
infoAdditiona parameter for visit function

Referenced by CNVisitElementOfObjectDictionary().