xref: /third_party/python/Include/setobject.h (revision 7db96d56)
1/* Set object interface */
2
3#ifndef Py_SETOBJECT_H
4#define Py_SETOBJECT_H
5#ifdef __cplusplus
6extern "C" {
7#endif
8
9PyAPI_DATA(PyTypeObject) PySet_Type;
10PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
11PyAPI_DATA(PyTypeObject) PySetIter_Type;
12
13PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
14PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
15
16PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
17PyAPI_FUNC(int) PySet_Clear(PyObject *set);
18PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
19PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
20PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
21PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
22
23#define PyFrozenSet_CheckExact(ob) Py_IS_TYPE(ob, &PyFrozenSet_Type)
24#define PyFrozenSet_Check(ob) \
25    (Py_IS_TYPE(ob, &PyFrozenSet_Type) || \
26      PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
27
28#define PyAnySet_CheckExact(ob) \
29    (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type))
30#define PyAnySet_Check(ob) \
31    (Py_IS_TYPE(ob, &PySet_Type) || Py_IS_TYPE(ob, &PyFrozenSet_Type) || \
32      PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \
33      PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type))
34
35#define PySet_CheckExact(op) Py_IS_TYPE(op, &PySet_Type)
36#define PySet_Check(ob) \
37    (Py_IS_TYPE(ob, &PySet_Type) || \
38    PyType_IsSubtype(Py_TYPE(ob), &PySet_Type))
39
40#ifndef Py_LIMITED_API
41#  define Py_CPYTHON_SETOBJECT_H
42#  include "cpython/setobject.h"
43#  undef Py_CPYTHON_SETOBJECT_H
44#endif
45
46#ifdef __cplusplus
47}
48#endif
49#endif /* !Py_SETOBJECT_H */
50