s2n_set.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #pragma once
  16. #include "api/s2n.h"
  17. #include "utils/s2n_array.h"
  18. #include "utils/s2n_result.h"
  19. struct s2n_set {
  20. struct s2n_array *data;
  21. int (*comparator)(const void *, const void *);
  22. };
  23. S2N_RESULT s2n_set_validate(const struct s2n_set *set);
  24. struct s2n_set *s2n_set_new(uint32_t element_size, int (*comparator)(const void *, const void *));
  25. S2N_RESULT s2n_set_add(struct s2n_set *set, void *element);
  26. S2N_RESULT s2n_set_get(struct s2n_set *set, uint32_t idx, void **element);
  27. S2N_RESULT s2n_set_remove(struct s2n_set *set, uint32_t idx);
  28. S2N_RESULT s2n_set_free_p(struct s2n_set **pset);
  29. S2N_RESULT s2n_set_free(struct s2n_set *set);
  30. S2N_RESULT s2n_set_len(struct s2n_set *set, uint32_t *len);