Orbiter 2022
Combinatorial Objects
set_of_sets_lint.cpp
Go to the documentation of this file.
1/*
2 * set_of_sets_lint.cpp
3 *
4 * Created on: Apr 26, 2019
5 * Author: betten
6 */
7
8
9#include "foundations.h"
10
11using namespace std;
12
13
14
15namespace orbiter {
16namespace layer1_foundations {
17namespace data_structures {
18
19
21{
22 null();
23}
24
26{
27 freeself();
28}
29
31{
33 nb_sets = 0;
34 Sets = NULL;
35 Set_size = NULL;
36}
37
39{
40 int i;
41
42 if (Sets) {
43 for (i = 0; i < nb_sets; i++) {
44 if (Sets[i]) {
45 FREE_lint(Sets[i]);
46 }
47 }
50 }
51 null();
52}
53
54void set_of_sets_lint::init_simple(long int underlying_set_size,
55 int nb_sets, int verbose_level)
56{
57 int f_v = (verbose_level >= 1);
58 int i;
59
60 if (f_v) {
61 cout << "set_of_sets_lint::init_simple nb_sets=" << nb_sets
62 << " underlying_set_size=" << underlying_set_size << endl;
63 }
68 for (i = 0; i < nb_sets; i++) {
69 Sets[i] = NULL;
70 }
72}
73
74void set_of_sets_lint::init(long int underlying_set_size,
75 int nb_sets, long int **Pts, int *Sz, int verbose_level)
76{
77 int f_v = (verbose_level >= 1);
78 int i;
79
80 if (f_v) {
81 cout << "set_of_sets_lint::init nb_sets=" << nb_sets
82 << " underlying_set_size=" << underlying_set_size << endl;
83 }
84
85 init_basic(underlying_set_size, nb_sets, Sz, verbose_level);
86
87 for (i = 0; i < nb_sets; i++) {
88 Lint_vec_copy(Pts[i], Sets[i], Sz[i]);
89 }
90}
91
92void set_of_sets_lint::init_basic(long int underlying_set_size,
93 int nb_sets, int *Sz, int verbose_level)
94{
95 int f_v = (verbose_level >= 1);
96 int i;
97
98 if (f_v) {
99 cout << "set_of_sets::init_basic nb_sets=" << nb_sets
100 << " underlying_set_size=" << underlying_set_size << endl;
101 }
106 for (i = 0; i < nb_sets; i++) {
107 Sets[i] = NULL;
108 }
109 for (i = 0; i < nb_sets; i++) {
110 Set_size[i] = Sz[i];
111 if (FALSE /*f_v*/) {
112 cout << "set_of_sets::init_basic allocating set " << i
113 << " of size " << Sz[i] << endl;
114 }
115 Sets[i] = NEW_lint(Sz[i]);
116 }
117}
118
119
120void set_of_sets_lint::init_set(int idx_of_set,
121 long int *set, int sz, int verbose_level)
122// Stores a copy of the given set.
123{
124 int f_v = (verbose_level >= 1);
125 int j;
126
127 if (f_v) {
128 cout << "set_of_sets_lint::init_set" << endl;
129 }
130 if (Sets[idx_of_set]) {
131 cout << "set_of_sets_lint::init_set Sets[idx_of_set] "
132 "is allocated" << endl;
133 exit(1);
134 }
135 Sets[idx_of_set] = NEW_lint(sz);
136 Set_size[idx_of_set] = sz;
137 for (j = 0; j < sz; j++) {
138 Sets[idx_of_set][j] = set[j];
139 }
140
141 if (f_v) {
142 cout << "set_of_sets_lint::init_set done" << endl;
143 }
144}
145
146
147
148}}}
149
150
151
void init(long int underlying_set_size, int nb_sets, long int **Pts, int *Sz, int verbose_level)
void init_simple(long int underlying_set_size, int nb_sets, int verbose_level)
void init_basic(long int underlying_set_size, int nb_sets, int *Sz, int verbose_level)
void init_set(int idx_of_set, long int *set, int sz, int verbose_level)
#define Lint_vec_copy(A, B, C)
Definition: foundations.h:694
#define NEW_plint(n)
Definition: foundations.h:629
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define FREE_plint(p)
Definition: foundations.h:643
#define NEW_int(n)
Definition: foundations.h:625
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects