Logo Search packages:      
Sourcecode: jalv version File versions  Download package

Classes | Functions

symap.c File Reference

#include <assert.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include "symap.h"
Include dependency graph for symap.c:

Go to the source code of this file.

Classes

struct  SymapImpl

Functions

void symap_free (Symap *map)
uint32_t symap_map (Symap *map, const char *sym)
Symapsymap_new ()
static uint32_t symap_search (const Symap *map, const char *sym, bool *exact)
static char * symap_strdup (const char *str)
uint32_t symap_try_map (Symap *map, const char *sym)
const char * symap_unmap (Symap *map, uint32_t id)

Detailed Description

Implementation of Symap, a basic symbol map (string interner).

This implementation is primitive, but has some desirable qualities: good (O(lg(n)) lookup performance for already-mapped symbols, minimal space overhead, extremely fast (O(1)) reverse mapping (ID to string), simple code, no dependencies.

The tradeoff is that mapping new symbols may be quite slow. In other words, this implementation is ideal for use cases with a relatively limited set of symbols, or where most symbols are mapped early. It will not fare so well with very dynamic sets of symbols. For that, you're better off with a tree-based implementation (and the associated space cost, especially if you need reverse mapping).

Definition in file symap.c.


Generated by  Doxygen 1.6.0   Back to index