An indexmap is basically a managed array of pointers, but it allows you to derive relatively quickly the index from a pointer in the array.
More...
|
t_indexmap * | indexmap_new (void) |
| Create a new indexmap object. More...
|
|
void | indexmap_append (t_indexmap *x, void *data) |
| Add an item to an indexmap. More...
|
|
t_max_err | indexmap_move (t_indexmap *x, void *data, long newindex) |
| Move an item to a different position in an indexmap. More...
|
|
t_max_err | indexmap_delete (t_indexmap *x, void *data) |
| Delete a specified item from an indexmap. More...
|
|
t_max_err | indexmap_delete_index (t_indexmap *x, long index) |
| Delete an item from the indexmap by index. More...
|
|
t_max_err | indexmap_delete_multi (t_indexmap *x, long count, void **pdata) |
| Delete multiple specified items from an indexmap. More...
|
|
t_max_err | indexmap_delete_index_multi (t_indexmap *x, long count, long *indices) |
| Delete multiple items from an indexmap by index. More...
|
|
void * | indexmap_datafromindex (t_indexmap *x, long index) |
| Get an item from an indexmap by index. More...
|
|
t_max_err | indexmap_indexfromdata (t_indexmap *x, void *data, long *index) |
| Find the index of an item given a pointer to the item. More...
|
|
long | indexmap_getsize (t_indexmap *x) |
| Return the number of items in an indexmap. More...
|
|
void | indexmap_clear (t_indexmap *x) |
| Delete all items in an indexmap. More...
|
|
void | indexmap_sort (t_indexmap *x, t_cmpfn fn) |
| Sort the items in an indexmap. More...
|
|
An indexmap is basically a managed array of pointers, but it allows you to derive relatively quickly the index from a pointer in the array.
The index is assumed to be 0-N (where N is the current size of the array). You can sort the data and retain access to an index from the data relatively quickly. There is a hashtab which holds pieces of memory that hold indices that can be referenced by the data pointer. There is also an array of data pointers – this is in "index" order. When operations take place on the array (insert, delete, sort), the pointers in the hashtab are updated with new indices.
void indexmap_append |
( |
t_indexmap * |
x, |
|
|
void * |
data |
|
) |
| |
Add an item to an indexmap.
- Parameters
-
x | The indexmap instance. |
data | The item to add. |
Delete all items in an indexmap.
- Parameters
-
void* indexmap_datafromindex |
( |
t_indexmap * |
x, |
|
|
long |
index |
|
) |
| |
Get an item from an indexmap by index.
- Parameters
-
x | The indexmap instance. |
index | The index from which to fetch a stored item. |
- Returns
- The item stored at the specified index.
Delete a specified item from an indexmap.
- Parameters
-
x | The indexmap instance. |
data | The item pointer to remove from the indexmap. |
- Returns
- A Max error code.
Delete an item from the indexmap by index.
- Parameters
-
x | The indexmap instance. |
index | The index of the item to remove from the indexmap. |
- Returns
- A Max error code.
Delete multiple items from an indexmap by index.
- Parameters
-
x | The indexmap instance. |
count | The number of items to remove from the indexmap. |
indices | The address of the first of an array of index numbers to remove the indexmap. |
- Returns
- A Max error code.
Delete multiple specified items from an indexmap.
- Parameters
-
x | The indexmap instance. |
count | The number of items to remove from the indexmap. |
pdata | The address of the first of an array of item pointers to remove from the indexmap. |
- Returns
- A Max error code.
Return the number of items in an indexmap.
- Parameters
-
- Returns
- The number of items in the indexmap.
Find the index of an item given a pointer to the item.
- Parameters
-
x | The indexmap instance. |
data | The item whose index you wish to look up. |
index | The address of a variable to hold the retrieved index. |
- Returns
- A Max error code.
Move an item to a different position in an indexmap.
- Parameters
-
x | The indexmap instance. |
data | The item in the indexmap to move. |
newindex | The new index to which to move the item. |
- Returns
- A Max error code.
Create a new indexmap object.
- Returns
- Pointer to the new indexmap object.
Sort the items in an indexmap.
Item are sorted using a t_cmpfn function that is passed in as an argument.
- Parameters
-
x | The indexmap instance. |
fn | The function used to sort the list. |
- See also
- linklist_sort()