aboutsummaryrefslogtreecommitdiff
path: root/src/multiset.h
diff options
context:
space:
mode:
authorLibravatar Comrade Martin Miroslavovich Michalec <martin@michalec.dev>2023-11-25 16:24:10 +0000
committerLibravatar Martin Michalec <martin@michalec.dev>2026-11-07 02:12:00 +0000
commitbca75f071153ddcaa5ceee0722e2152bacfedc78 (patch)
tree7c42e4aa83103aa9813151e4251d2ffb4023ffbe /src/multiset.h
downloadlab-01-master.tar.gz
publishHEADmaster
Diffstat (limited to 'src/multiset.h')
-rw-r--r--src/multiset.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/multiset.h b/src/multiset.h
new file mode 100644
index 0000000..6e1a8c9
--- /dev/null
+++ b/src/multiset.h
@@ -0,0 +1,36 @@
1#ifndef MULTISET_H
2#define MULTISET_H
3
4#include <stdlib.h>
5#include <string.h>
6#include "utils.h"
7
8struct multiset_element
9{
10 uint value;
11 uint count;
12};
13
14typedef struct multiset
15{
16 uint power;
17 struct multiset_element elements[0];
18} *MULTISET;
19
20MULTISET init_multiset (uint power);
21int compare_multiset_elements (const void *lhs, const void *rhs);
22uint multiset_get (MULTISET ms, uint value);
23MULTISET multiset_set (MULTISET ms, uint value, uint count);
24uint multiset_element_max_count (MULTISET ms);
25MULTISET multiset_copy (MULTISET ms);
26MULTISET multiset_union (MULTISET lhs, MULTISET rhs);
27MULTISET multiset_intersection (MULTISET lhs, MULTISET rhs);
28MULTISET multiset_complement (MULTISET ms, MULTISET u);
29MULTISET multiset_difference (MULTISET lhs, MULTISET rhs);
30MULTISET multiset_arithmetic_sum (MULTISET lhs, MULTISET rhs, MULTISET u);
31MULTISET multiset_arithmetic_difference (MULTISET lhs, MULTISET rhs);
32MULTISET multiset_arithmetic_multiplication (MULTISET lhs, MULTISET rhs, MULTISET u);
33MULTISET multiset_arithmetic_division (MULTISET lhs, MULTISET rhs, MULTISET u);
34MULTISET multiset_symmetrical_difference (MULTISET lhs, MULTISET rhs);
35
36#endif