Quick Map

A quickmap implements a pair of t_hashtab hash tables so that it is fast to look up a unique value for a unique key or vice-versa. More...

+ Collaboration diagram for Quick Map:

Data Structures

struct  t_quickmap
 The quickmap object. More...

Functions

BEGIN_USING_C_LINKAGE void * quickmap_new (void)
 Create a new quickmap object.
void quickmap_add (t_quickmap *x, void *p1, void *p2)
 Add a pair of keys mapped to each other to the quickmap.
void quickmap_drop (t_quickmap *x, void *p1, void *p2)
 Drop a pair of keys mapped to each other in the quickmap.
long quickmap_lookup_key1 (t_quickmap *x, void *p1, void **p2)
 Given a (first) key, lookup the value (the second key).
long quickmap_lookup_key2 (t_quickmap *x, void *p1, void **p2)
 Given a (second) key, lookup the value (the first key).
void quickmap_readonly (t_quickmap *x, long way)
 Set the readonly flag of the quickmap's hash tables.

Detailed Description

A quickmap implements a pair of t_hashtab hash tables so that it is fast to look up a unique value for a unique key or vice-versa.

This implies that both the keys and the values must be unique so that look-ups can be performed in both directions.


Function Documentation

void quickmap_add ( t_quickmap x,
void *  p1,
void *  p2 
)

Add a pair of keys mapped to each other to the quickmap.

Note that these are considered to be a t_symbol internally. This means that if you are mapping a t_symbol to a t_object, for example, the t_object will not automatically be freed when you free the quickmap (unlike what happens when you typically free a t_hashtab).

Parameters:
xThe quickmap instance.
p1The (first) key.
p2The value (or the second key).
Returns:
A Max error code.
void quickmap_drop ( t_quickmap x,
void *  p1,
void *  p2 
)

Drop a pair of keys mapped to each other in the quickmap.

Parameters:
xThe quickmap instance.
p1The first key.
p2The second key.
Returns:
A Max error code.
long quickmap_lookup_key1 ( t_quickmap x,
void *  p1,
void **  p2 
)

Given a (first) key, lookup the value (the second key).

Parameters:
xThe quickmap instance.
p1The (first) key.
p2The address of a pointer which will hold the resulting key upon return.
Returns:
A Max error code.
long quickmap_lookup_key2 ( t_quickmap x,
void *  p1,
void **  p2 
)

Given a (second) key, lookup the value (the first key).

Parameters:
xThe quickmap instance.
p1The (second) key.
p2The address of a pointer which will hold the resulting key upon return.
Returns:
A Max error code.
BEGIN_USING_C_LINKAGE void* quickmap_new ( void  )

Create a new quickmap object.

Returns:
Pointer to the new quickmap object.
void quickmap_readonly ( t_quickmap x,
long  way 
)

Set the readonly flag of the quickmap's hash tables.

See hashtab_readonly() for more information about this.

Parameters:
xThe quickmap instance.
waySet to true to make the quickmap readonly (disable thread protection) or false (the default) to enable thread protection.