github.com/256dpi/max-go@v0.7.0/lib/max/ext_quickmap.h (about) 1 2 #ifndef __QUICKMAP_H__ 3 #define __QUICKMAP_H__ 4 5 #include "ext_prefix.h" 6 #include "ext_mess.h" 7 #include "ext_hashtab.h" 8 9 #if C74_PRAGMA_STRUCT_PACKPUSH 10 #pragma pack(push, 2) 11 #elif C74_PRAGMA_STRUCT_PACK 12 #pragma pack(2) 13 #endif 14 15 16 /** The quickmap object. This struct is provided for debugging convenience, 17 but should be considered opaque and is subject to change without notice. 18 19 @ingroup quickmap 20 */ 21 typedef struct _quickmap { 22 t_object m_obj; 23 t_hashtab *m_p1key; 24 t_hashtab *m_p2key; 25 } t_quickmap; 26 27 28 #if C74_PRAGMA_STRUCT_PACKPUSH 29 #pragma pack(pop) 30 #elif C74_PRAGMA_STRUCT_PACK 31 #pragma pack() 32 #endif 33 34 35 BEGIN_USING_C_LINKAGE 36 37 /** 38 Create a new quickmap object. 39 40 @ingroup quickmap 41 @return Pointer to the new quickmap object. 42 */ 43 void *quickmap_new(void); 44 45 46 /** 47 Add a pair of keys mapped to each other to the quickmap. 48 Note that these are considered to be a #t_symbol internally. 49 This means that if you are mapping a #t_symbol to a #t_object, for example, the #t_object will not automatically be 50 freed when you free the quickmap (unlike what happens when you typically free a #t_hashtab). 51 52 @ingroup quickmap 53 54 @param x The quickmap instance. 55 @param p1 The (first) key. 56 @param p2 The value (or the second key). 57 @return A Max error code. 58 */ 59 void quickmap_add(t_quickmap *x, void *p1, void *p2); 60 61 62 /** 63 Drop a pair of keys mapped to each other in the quickmap. 64 65 @ingroup quickmap 66 67 @param x The quickmap instance. 68 @param p1 The first key. 69 @param p2 The second key. 70 @return A Max error code. 71 */ 72 void quickmap_drop(t_quickmap *x, void *p1, void *p2); 73 74 75 /** 76 Given a (first) key, lookup the value (the second key). 77 78 @ingroup quickmap 79 80 @param x The quickmap instance. 81 @param p1 The (first) key. 82 @param p2 The address of a pointer which will hold the resulting key upon return. 83 @return A Max error code. 84 */ 85 long quickmap_lookup_key1(t_quickmap *x, void *p1, void **p2); 86 87 88 /** 89 Given a (second) key, lookup the value (the first key). 90 91 @ingroup quickmap 92 93 @param x The quickmap instance. 94 @param p1 The (second) key. 95 @param p2 The address of a pointer which will hold the resulting key upon return. 96 @return A Max error code. 97 */ 98 long quickmap_lookup_key2(t_quickmap *x, void *p1, void **p2); 99 100 101 /** 102 Set the readonly flag of the quickmap's hash tables. 103 See hashtab_readonly() for more information about this. 104 105 @ingroup quickmap 106 107 @param x The quickmap instance. 108 @param way Set to true to make the quickmap readonly (disable thread protection) 109 or false (the default) to enable thread protection. 110 */ 111 void quickmap_readonly(t_quickmap *x, long way); 112 113 114 END_USING_C_LINKAGE 115 116 #endif // __QUICKMAP_H__