9836d427efcba2c75e34c4077cf96b12c71e9610
   1#include "cache.h"
   2#include "oidset.h"
   3
   4int oidset_contains(const struct oidset *set, const struct object_id *oid)
   5{
   6        khiter_t pos = kh_get_oid(&set->set, *oid);
   7        return pos != kh_end(&set->set);
   8}
   9
  10int oidset_insert(struct oidset *set, const struct object_id *oid)
  11{
  12        int added;
  13        kh_put_oid(&set->set, *oid, &added);
  14        return !added;
  15}
  16
  17int oidset_remove(struct oidset *set, const struct object_id *oid)
  18{
  19        khiter_t pos = kh_get_oid(&set->set, *oid);
  20        if (pos == kh_end(&set->set))
  21                return 0;
  22        kh_del_oid(&set->set, pos);
  23        return 1;
  24}
  25
  26void oidset_clear(struct oidset *set)
  27{
  28        kh_release_oid(&set->set);
  29        oidset_init(set, 0);
  30}