File: set.h

package info (click to toggle)
phoc 0.51.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,948 kB
  • sloc: ansic: 106,056; xml: 3,765; sh: 138; makefile: 33; javascript: 5
file content (29 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef UTIL_SET_H
#define UTIL_SET_H

#include <stdint.h>
#include <stdbool.h>
#include <sys/types.h>

/**
 * Add target to values.
 *
 * Target is added to the end of the set.
 *
 * Returns the index of target, or -1 if the set is full or target already
 * exists.
 */
ssize_t set_add(uint32_t values[], size_t *len, size_t cap, uint32_t target);

/**
 * Remove target from values.
 *
 * When target is removed, the last element of the set is moved to where
 * target was.
 *
 * Returns the previous index of target, or -1 if target wasn't in values.
 */
ssize_t set_remove(uint32_t values[], size_t *len, size_t cap, uint32_t target);

#endif