Debian Codegraph @

src/h/ST_rank_t.java

raw symbols SCIP
1 /* ========================================================================
2 * PlantUML : a free UML diagram generator
3 * ========================================================================
4 *
5 * Project Info: http://plantuml.com
6 *
7 * If you like this project or if you find it useful, you can support us at:
8 *
9 * http://plantuml.com/patreon (only 1$ per month!)
10 * http://plantuml.com/paypal
11 *
12 * This file is part of Smetana.
13 * Smetana is a partial translation of Graphviz/Dot sources from C to Java.
14 *
15 * (C) Copyright 2009-2020, Arnaud Roques
16 *
17 * This translation is distributed under the same Licence as the original C program:
18 *
19 *************************************************************************
20 * Copyright (c) 2011 AT&T Intellectual Property
21 * All rights reserved. This program and the accompanying materials
22 * are made available under the terms of the Eclipse Public License v1.0
23 * which accompanies this distribution, and is available at
24 * http://www.eclipse.org/legal/epl-v10.html
25 *
26 * Contributors: See CVS logs. Details at http://www.graphviz.org/
27 *************************************************************************
28 *
29 * THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
30 * LICENSE ("AGREEMENT"). [Eclipse Public License - v 1.0]
31 *
32 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES
33 * RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
34 *
35 * You may obtain a copy of the License at
36 *
37 * http://www.eclipse.org/legal/epl-v10.html
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS,
41 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 *
45 */
46 package h;
47
48 import java.util.ArrayList;
49 import java.util.List;
50
51 import smetana.core.UnsupportedArrayOfPtr;
52 import smetana.core.UnsupportedStructAndPtr;
53 import smetana.core.__array_of_ptr__;
54 import smetana.core.__ptr__;
55 import smetana.core.__struct__;
56 import smetana.core.amiga.StarStruct;
57
58 public class ST_rank_t extends UnsupportedStructAndPtr {
59
60 private final StarStruct parent;
61
62 public ST_rank_t() {
63 this(null);
64 }
65
66 public ST_rank_t(StarStruct parent) {
67 this.parent = parent;
68 }
69
70 public int n;
71
72 // "node_t **v",
73 public ST_Agnode_s.ArrayOfStar v;
74 public int an;
75 // "node_t **av",
76 public ST_Agnode_s.ArrayOfStar av;
77
78 public double ht1, ht2;
79 public double pht1, pht2;
80 public boolean candidate;
81 public int valid;
82
83 public int cache_nc;
84 public ST_adjmatrix_t flat;
85
86 // "}",
87 // "rank_t");
88
89
90 public static class Array2 extends UnsupportedArrayOfPtr implements __ptr__, __array_of_ptr__ {
91
92 private final List<ST_rank_t> data;
93 private final int pos;
94
95 public Array2(int size) {
96 this.data = new ArrayList<ST_rank_t>();
97 this.pos = 0;
98 for (int i = 0; i < size; i++) {
99 data.add(new ST_rank_t());
100 }
101 }
102
103 @Override
104 public void setInt(String fieldName, int data) {
105 getPtr().setInt(fieldName, data);
106 }
107
108 @Override
109 public __ptr__ setPtr(String fieldName, __ptr__ newData) {
110 return getPtr().setPtr(fieldName, newData);
111 }
112
113 @Override
114 public void setDouble(String fieldName, double data) {
115 getPtr().setDouble(fieldName, data);
116 }
117
118 public ST_rank_t get(int i) {
119 return plus(i).getPtr();
120 }
121
122 public void swap(int i, int j) {
123 ST_rank_t e1 = data.get(i);
124 ST_rank_t e2 = data.get(j);
125 data.set(i, e2);
126 data.set(j, e1);
127 }
128
129 public Array2(List<ST_rank_t> data, int pos) {
130 this.data = data;
131 this.pos = pos;
132 }
133
134 public Array2 reallocJ(int newsize) {
135 while (data.size() < newsize) {
136 data.add(new ST_rank_t());
137 }
138 return this;
139 }
140
141 @Override
142 public Array2 plus(int delta) {
143 return new Array2(data, pos + delta);
144 }
145
146 @Override
147 public Array2 asPtr() {
148 return this;
149 }
150
151 @Override
152 public void setPtr(__ptr__ value) {
153 // if (value instanceof Amp) {
154 // value = value.getPtr();
155 // }
156 this.data.set(pos, (ST_rank_t) value);
157 }
158
159 @Override
160 public ST_rank_t getPtr() {
161 return this.data.get(pos);
162 }
163
164 @Override
165 public int comparePointer(__ptr__ other) {
166 final Array2 this2 = (Array2) other;
167 if (this.data != this2.data) {
168 throw new IllegalArgumentException();
169 }
170 return this.pos - this2.pos;
171 }
172
173 public boolean isSameThan2(Array2 other) {
174 if (this.data != other.data) {
175 throw new IllegalArgumentException();
176 }
177 return this.pos == other.pos;
178 }
179 }
180
181
182 @Override
183 public void setStruct(__struct__ value) {
184 ST_rank_t this2 = (ST_rank_t) value;
185 this.n = this2.n;
186 this.v = this2.v;
187 this.an = this2.an;
188 this.av = this2.av;
189 this.ht1 = this2.ht1;
190 this.ht2 = this2.ht2;
191 this.pht1 = this2.pht1;
192 this.pht2 = this2.pht2;
193 this.candidate = this2.candidate;
194 this.valid = this2.valid;
195 this.cache_nc = this2.cache_nc;
196 this.flat = this2.flat;
197 }
198
199
200 @Override
201 public void setInt(String fieldName, int data) {
202 if (fieldName.equals("n")) {
203 this.n = data;
204 return;
205 }
206 if (fieldName.equals("an")) {
207 this.an = data;
208 return;
209 }
210 if (fieldName.equals("valid")) {
211 this.valid = data;
212 return;
213 }
214 if (fieldName.equals("cache_nc")) {
215 this.cache_nc = data;
216 return;
217 }
218 super.setInt(fieldName, data);
219 }
220
221 @Override
222 public void setDouble(String fieldName, double data) {
223 if (fieldName.equals("pht1")) {
224 this.pht1 = data;
225 return;
226 }
227 if (fieldName.equals("pht2")) {
228 this.pht2 = data;
229 return;
230 }
231 if (fieldName.equals("ht1")) {
232 this.ht1 = data;
233 return;
234 }
235 if (fieldName.equals("ht2")) {
236 this.ht2 = data;
237 return;
238 }
239 super.setDouble(fieldName, data);
240 }
241
242 @Override
243 public __struct__ getStruct() {
244 return this;
245 }
246
247 @Override
248 public __ptr__ setPtr(String fieldName, __ptr__ newData) {
249 if (fieldName.equals("v")) {
250 this.v = (ST_Agnode_s.ArrayOfStar) newData;
251 return v;
252 }
253 if (fieldName.equals("av")) {
254 this.av = (ST_Agnode_s.ArrayOfStar) newData;
255 return av;
256 }
257 if (fieldName.equals("flat")) {
258 this.flat = (ST_adjmatrix_t) newData;
259 return flat;
260 }
261 return super.setPtr(fieldName, newData);
262 }
263
264 // public static size_t sizeof(final int nb) {
265 // return new UnsupportedSize_t(nb) {
266 // @Override
267 // public Array2 malloc() {
268 // return new Array2(nb);
269 // }
270 //
271 // @Override
272 // public int getInternalNb() {
273 // return nb;
274 // }
275 //
276 // @Override
277 // public Array2 realloc(Object old) {
278 // Array2 old2 = (Array2) old;
279 // old2.reallocJ(nb);
280 // return old2;
281 // }
282 // };
283 // }
284
285 }
286
287 // typedef struct rank_t {
288 // int n; /* number of nodes in this rank */
289 // node_t **v; /* ordered list of nodes in rank */
290 // int an; /* globally allocated number of nodes */
291 // node_t **av; /* allocated list of nodes in rank */
292 // double ht1, ht2; /* height below/above centerline */
293 // double pht1, pht2; /* as above, but only primitive nodes */
294 // boolean candidate; /* for transpose () */
295 // boolean valid;
296 // int cache_nc; /* caches number of crossings */
297 // adjmatrix_t *flat;
298 // } rank_t;