Max API  8.0.2
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...

Data Structures

struct  t_quickmap
 The quickmap object. More...
 

Functions

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

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

◆ quickmap_add()

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.

◆ quickmap_drop()

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.

◆ quickmap_lookup_key1()

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.

◆ quickmap_lookup_key2()

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.

◆ quickmap_new()

BEGIN_USING_C_LINKAGE void* quickmap_new ( void  )

Create a new quickmap object.

Returns
Pointer to the new quickmap object.

◆ quickmap_readonly()

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.