Add wrapper for DBEnv.set_tx_timeout method to allow time based DB_RECOVER
[python.git] / Include / setobject.h
blob1b0e5b12cd971ec2456497b6ba49de9ebca2e198
1 /* Set object interface */
3 #ifndef Py_SETOBJECT_H
4 #define Py_SETOBJECT_H
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
11 There are three kinds of slots in the table:
13 1. Unused: key == NULL
14 2. Active: key != NULL and key != dummy
15 3. Dummy: key == dummy
17 Note: .pop() abuses the hash field of an Unused or Dummy slot to
18 hold a search finger. The hash field of Unused or Dummy slots has
19 no meaning otherwise.
22 #define PySet_MINSIZE 8
24 typedef struct {
25 long hash; /* cached hash code for the entry key */
26 PyObject *key;
27 } setentry;
31 This data structure is shared by set and frozenset objects.
34 typedef struct _setobject PySetObject;
35 struct _setobject {
36 PyObject_HEAD
38 int fill; /* # Active + # Dummy */
39 int used; /* # Active */
41 /* The table contains mask + 1 slots, and that's a power of 2.
42 * We store the mask instead of the size because the mask is more
43 * frequently needed.
45 int mask;
47 /* table points to smalltable for small tables, else to
48 * additional malloc'ed memory. table is never NULL! This rule
49 * saves repeated runtime null-tests.
51 setentry *table;
52 setentry *(*lookup)(PySetObject *so, PyObject *key, long hash);
53 setentry smalltable[PySet_MINSIZE];
55 long hash; /* only used by frozenset objects */
56 PyObject *weakreflist; /* List of weak references */
59 PyAPI_DATA(PyTypeObject) PySet_Type;
60 PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
62 /* Invariants for frozensets:
63 * data is immutable.
64 * hash is the hash of the frozenset or -1 if not computed yet.
65 * Invariants for sets:
66 * hash is -1
69 #define PyFrozenSet_CheckExact(ob) ((ob)->ob_type == &PyFrozenSet_Type)
70 #define PyAnySet_CheckExact(ob) \
71 ((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type)
72 #define PyAnySet_Check(ob) \
73 ((ob)->ob_type == &PySet_Type || (ob)->ob_type == &PyFrozenSet_Type || \
74 PyType_IsSubtype((ob)->ob_type, &PySet_Type) || \
75 PyType_IsSubtype((ob)->ob_type, &PyFrozenSet_Type))
77 PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
78 PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
79 PyAPI_FUNC(int) PySet_Size(PyObject *anyset);
80 #define PySet_GET_SIZE(so) (((PySetObject *)(so))->used)
81 PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
82 PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
83 PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
84 PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
86 #ifdef __cplusplus
88 #endif
89 #endif /* !Py_SETOBJECT_H */