setobject.h 1.5 KB

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