bintree.h 735 B

12345678910111213141516171819202122232425
  1. #pragma once
  2. #include "pocketpy/objects/base.h"
  3. #include "pocketpy/common/vector.h"
  4. #include "pocketpy/pocketpy.h"
  5. typedef struct BinTreeConfig {
  6. int (*f_cmp)(void* lhs, void* rhs);
  7. bool need_free_key;
  8. } BinTreeConfig;
  9. typedef struct BinTree {
  10. void* key;
  11. py_TValue value;
  12. const BinTreeConfig* config;
  13. struct BinTree* left;
  14. struct BinTree* right;
  15. } BinTree;
  16. void BinTree__ctor(BinTree* self, void* key, py_Ref value, const BinTreeConfig* config);
  17. void BinTree__dtor(BinTree* self);
  18. void BinTree__set(BinTree* self, void* key, py_Ref value);
  19. py_Ref BinTree__try_get(BinTree* self, void* key);
  20. bool BinTree__contains(BinTree* self, void* key);
  21. void BinTree__apply_mark(BinTree* self, c11_vector* p_stack);