calg.pxd 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. cdef extern from 'set.h':
  2. #ctypedef _Set Set
  3. #ctypedef _SetEntry SetEntry
  4. ctypedef void *SetValue
  5. ctypedef struct SetEntry:
  6. SetValue data
  7. SetEntry *next
  8. ctypedef struct Set:
  9. SetEntry **table
  10. unsigned int entries
  11. unsigned int table_size
  12. unsigned int prime_index
  13. #SetHashFunc hash_func
  14. #SetEqualFunc equal_func
  15. #SetFreeFunc free_func
  16. ctypedef struct SetIterator:
  17. pass
  18. ctypedef unsigned int (*SetHashFunc)(SetValue value)
  19. ctypedef bint (*SetEqualFunc)(SetValue value1, SetValue value2)
  20. ctypedef void (*SetFreeFunc)(SetValue value)
  21. Set *set_new(SetHashFunc hash_func, SetEqualFunc equal_func)
  22. void set_free(Set *set)
  23. # TODO This should return an int, ideally. See
  24. # https://github.com/fragglet/c-algorithms/issues/20
  25. bint set_insert(Set *set, SetValue data)
  26. bint set_query(Set *set, SetValue data)
  27. unsigned int set_num_entries(Set *set)
  28. SetValue *set_to_array(Set *set)
  29. Set *set_union(Set *set1, Set *set2)
  30. Set *set_intersection(Set *set1, Set *set2)
  31. void set_iterate(Set *set, SetIterator *iter)
  32. bint set_iter_has_more(SetIterator *iterator)
  33. SetValue set_iter_next(SetIterator *iterator)