File indexing completed on 2025-01-30 10:18:08
0001 #ifndef Py_INTERNAL_HAMT_H
0002 #define Py_INTERNAL_HAMT_H
0003
0004 #ifndef Py_BUILD_CORE
0005 # error "this header requires Py_BUILD_CORE define"
0006 #endif
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #define _Py_HAMT_MAX_TREE_DEPTH 8
0021
0022
0023 extern PyTypeObject _PyHamt_Type;
0024 extern PyTypeObject _PyHamt_ArrayNode_Type;
0025 extern PyTypeObject _PyHamt_BitmapNode_Type;
0026 extern PyTypeObject _PyHamt_CollisionNode_Type;
0027 extern PyTypeObject _PyHamtKeys_Type;
0028 extern PyTypeObject _PyHamtValues_Type;
0029 extern PyTypeObject _PyHamtItems_Type;
0030
0031
0032
0033
0034 #define PyHamt_Check(o) Py_IS_TYPE((o), &_PyHamt_Type)
0035
0036
0037
0038 typedef struct {
0039 PyObject_HEAD
0040 } PyHamtNode;
0041
0042
0043
0044 typedef struct {
0045 PyObject_HEAD
0046 PyHamtNode *h_root;
0047 PyObject *h_weakreflist;
0048 Py_ssize_t h_count;
0049 } PyHamtObject;
0050
0051
0052 typedef struct {
0053 PyObject_VAR_HEAD
0054 uint32_t b_bitmap;
0055 PyObject *b_array[1];
0056 } PyHamtNode_Bitmap;
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071 typedef struct {
0072 PyHamtNode *i_nodes[_Py_HAMT_MAX_TREE_DEPTH];
0073 Py_ssize_t i_pos[_Py_HAMT_MAX_TREE_DEPTH];
0074 int8_t i_level;
0075 } PyHamtIteratorState;
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086 typedef struct {
0087 PyObject_HEAD
0088 PyHamtObject *hi_obj;
0089 PyHamtIteratorState hi_iter;
0090 binaryfunc hi_yield;
0091 } PyHamtIterator;
0092
0093
0094
0095 PyHamtObject * _PyHamt_New(void);
0096
0097
0098
0099 PyHamtObject * _PyHamt_Assoc(PyHamtObject *o, PyObject *key, PyObject *val);
0100
0101
0102 PyHamtObject * _PyHamt_Without(PyHamtObject *o, PyObject *key);
0103
0104
0105
0106
0107
0108
0109
0110
0111 int _PyHamt_Find(PyHamtObject *o, PyObject *key, PyObject **val);
0112
0113
0114
0115
0116
0117
0118
0119
0120 int _PyHamt_Eq(PyHamtObject *v, PyHamtObject *w);
0121
0122
0123 Py_ssize_t _PyHamt_Len(PyHamtObject *o);
0124
0125
0126 PyObject * _PyHamt_NewIterKeys(PyHamtObject *o);
0127
0128
0129 PyObject * _PyHamt_NewIterValues(PyHamtObject *o);
0130
0131
0132 PyObject * _PyHamt_NewIterItems(PyHamtObject *o);
0133
0134 #endif