cmap - /* * File: cmap.h * -* Defines the interface for the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/** * File: cmap.h * ------------ * Defines the interface for the CMap type. * * The CMap manages a collection of key-value pairs. The keys are always * of type char *, but the values can be of any desired type. The * main operations are to associate a value with a key and to retrieve * the value associated with a key. In order to work for all types of values, * all CMap values must be passed and returned via (void *) pointers. * Given its extensive use of untyped pointers, the CMap is a bit tricky * to use correctly as a client. Be diligent! * * CS107 Spring 2010 jzelenski */ #ifndef _cmap_h #define _cmap_h /** * Type: CMapMapEntryFn * -------------------- * CMapMapEntryFn is the typename for a pointer to a client-supplied mapping * function passed to CMap to apply to each entry. The map function takes * a char *key, a void * pointer to its associated value, and another void * for * extra data pointer passed by the client. */ typedef void (*CMapMapEntryFn)(char *key, void *valueAddr, void *auxData); /** * Type: CMapFreeValueFn * --------------------- * CMapFreeValueFn is the typename for a pointer to a client-supplied function * passed to CMap to apply to a value being removed/freed. The free function * takes one void * pointer that points to the value about to be removed/freed. */ typedef void (*CMapFreeValueFn)(void *valueAddr); /** * Type: CMap * ---------- * Defines the concrete representation of the CMap internals. * Even though its private fields are listed here, the client is expected * to respect the privacy of the representation. Clients should declare * variables only of type CMap * (never of CMap struct) and
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/24/2012 for the course CS 107 taught by Professor Cain,g during the Spring '08 term at Stanford.

Page1 / 3

cmap - /* * File: cmap.h * -* Defines the interface for the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online