comparison src/main/java/fj/P6.java @ 0:fe80c1edf1be

add getLoop
author tatsuki
date Fri, 20 Mar 2015 21:04:03 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fe80c1edf1be
1 package fj;
2
3 /**
4 * A product-6.
5 *
6 * @version %build.number%
7 */
8 @SuppressWarnings({"UnnecessaryFullyQualifiedName"})
9 public abstract class P6<A, B, C, D, E, F> {
10 /**
11 * Access the first element of the product.
12 *
13 * @return The first element of the product.
14 */
15 public abstract A _1();
16
17 /**
18 * Access the second element of the product.
19 *
20 * @return The second element of the product.
21 */
22 public abstract B _2();
23
24 /**
25 * Access the third element of the product.
26 *
27 * @return The third element of the product.
28 */
29 public abstract C _3();
30
31 /**
32 * Access the fourth element of the product.
33 *
34 * @return The fourth element of the product.
35 */
36 public abstract D _4();
37
38 /**
39 * Access the fifth element of the product.
40 *
41 * @return The fifth element of the product.
42 */
43 public abstract E _5();
44
45 /**
46 * Access the sixth element of the product.
47 *
48 * @return The sixth element of the product.
49 */
50 public abstract F _6();
51
52 /**
53 * Map the first element of the product.
54 *
55 * @param f The function to map with.
56 * @return A product with the given function applied.
57 */
58 public final <X> P6<X, B, C, D, E, F> map1(final fj.F<A, X> f) {
59 return new P6<X, B, C, D, E, F>() {
60 public X _1() {
61 return f.f(P6.this._1());
62 }
63
64 public B _2() {
65 return P6.this._2();
66 }
67
68 public C _3() {
69 return P6.this._3();
70 }
71
72 public D _4() {
73 return P6.this._4();
74 }
75
76 public E _5() {
77 return P6.this._5();
78 }
79
80 public F _6() {
81 return P6.this._6();
82 }
83 };
84 }
85
86 /**
87 * Map the second element of the product.
88 *
89 * @param f The function to map with.
90 * @return A product with the given function applied.
91 */
92 public final <X> P6<A, X, C, D, E, F> map2(final fj.F<B, X> f) {
93 return new P6<A, X, C, D, E, F>() {
94 public A _1() {
95 return P6.this._1();
96 }
97
98 public X _2() {
99 return f.f(P6.this._2());
100 }
101
102 public C _3() {
103 return P6.this._3();
104 }
105
106 public D _4() {
107 return P6.this._4();
108 }
109
110 public E _5() {
111 return P6.this._5();
112 }
113
114 public F _6() {
115 return P6.this._6();
116 }
117 };
118 }
119
120 /**
121 * Map the third element of the product.
122 *
123 * @param f The function to map with.
124 * @return A product with the given function applied.
125 */
126 public final <X> P6<A, B, X, D, E, F> map3(final fj.F<C, X> f) {
127 return new P6<A, B, X, D, E, F>() {
128 public A _1() {
129 return P6.this._1();
130 }
131
132 public B _2() {
133 return P6.this._2();
134 }
135
136 public X _3() {
137 return f.f(P6.this._3());
138 }
139
140 public D _4() {
141 return P6.this._4();
142 }
143
144 public E _5() {
145 return P6.this._5();
146 }
147
148 public F _6() {
149 return P6.this._6();
150 }
151 };
152 }
153
154 /**
155 * Map the fourth element of the product.
156 *
157 * @param f The function to map with.
158 * @return A product with the given function applied.
159 */
160 public final <X> P6<A, B, C, X, E, F> map4(final fj.F<D, X> f) {
161 return new P6<A, B, C, X, E, F>() {
162 public A _1() {
163 return P6.this._1();
164 }
165
166 public B _2() {
167 return P6.this._2();
168 }
169
170 public C _3() {
171 return P6.this._3();
172 }
173
174 public X _4() {
175 return f.f(P6.this._4());
176 }
177
178 public E _5() {
179 return P6.this._5();
180 }
181
182 public F _6() {
183 return P6.this._6();
184 }
185 };
186 }
187
188 /**
189 * Map the fifth element of the product.
190 *
191 * @param f The function to map with.
192 * @return A product with the given function applied.
193 */
194 public final <X> P6<A, B, C, D, X, F> map5(final fj.F<E, X> f) {
195 return new P6<A, B, C, D, X, F>() {
196 public A _1() {
197 return P6.this._1();
198 }
199
200 public B _2() {
201 return P6.this._2();
202 }
203
204 public C _3() {
205 return P6.this._3();
206 }
207
208 public D _4() {
209 return P6.this._4();
210 }
211
212 public X _5() {
213 return f.f(P6.this._5());
214 }
215
216 public F _6() {
217 return P6.this._6();
218 }
219 };
220 }
221
222 /**
223 * Map the sixth element of the product.
224 *
225 * @param f The function to map with.
226 * @return A product with the given function applied.
227 */
228 public final <X> P6<A, B, C, D, E, X> map6(final fj.F<F, X> f) {
229 return new P6<A, B, C, D, E, X>() {
230 public A _1() {
231 return P6.this._1();
232 }
233
234 public B _2() {
235 return P6.this._2();
236 }
237
238 public C _3() {
239 return P6.this._3();
240 }
241
242 public D _4() {
243 return P6.this._4();
244 }
245
246 public E _5() {
247 return P6.this._5();
248 }
249
250 public X _6() {
251 return f.f(P6.this._6());
252 }
253 };
254 }
255
256 /**
257 * Returns the 1-product projection over the first element.
258 *
259 * @return the 1-product projection over the first element.
260 */
261 public final P1<A> _1_() {
262 return F1Functions.lazy(P6.<A, B, C, D, E, F>__1()).f(this);
263 }
264
265 /**
266 * Returns the 1-product projection over the second element.
267 *
268 * @return the 1-product projection over the second element.
269 */
270 public final P1<B> _2_() {
271 return F1Functions.lazy(P6.<A, B, C, D, E, F>__2()).f(this);
272 }
273
274 /**
275 * Returns the 1-product projection over the third element.
276 *
277 * @return the 1-product projection over the third element.
278 */
279 public final P1<C> _3_() {
280 return F1Functions.lazy(P6.<A, B, C, D, E, F>__3()).f(this);
281 }
282
283 /**
284 * Returns the 1-product projection over the fourth element.
285 *
286 * @return the 1-product projection over the fourth element.
287 */
288 public final P1<D> _4_() {
289 return F1Functions.lazy(P6.<A, B, C, D, E, F>__4()).f(this);
290 }
291
292 /**
293 * Returns the 1-product projection over the fifth element.
294 *
295 * @return the 1-product projection over the fifth element.
296 */
297 public final P1<E> _5_() {
298 return F1Functions.lazy(P6.<A, B, C, D, E, F>__5()).f(this);
299 }
300
301 /**
302 * Returns the 1-product projection over the sixth element.
303 *
304 * @return the 1-product projection over the sixth element.
305 */
306 public final P1<F> _6_() {
307 return F1Functions.lazy(P6.<A, B, C, D, E, F>__6()).f(this);
308 }
309
310 /**
311 * Provides a memoising P6 that remembers its values.
312 *
313 * @return A P6 that calls this P6 once for any given element and remembers the value for subsequent calls.
314 */
315 public final P6<A, B, C, D, E, F> memo() {
316 P6<A, B, C, D, E, F> self = this;
317 return new P6<A, B, C, D, E, F>() {
318 private final P1<A> a = P1.memo(u -> self._1());
319 private final P1<B> b = P1.memo(u -> self._2());
320 private final P1<C> c = P1.memo(u -> self._3());
321 private final P1<D> d = P1.memo(u -> self._4());
322 private final P1<E> e = P1.memo(u -> self._5());
323 private final P1<F> f = P1.memo(u -> self._6());
324
325 public A _1() {
326 return a._1();
327 }
328
329 public B _2() {
330 return b._1();
331 }
332
333 public C _3() {
334 return c._1();
335 }
336
337 public D _4() {
338 return d._1();
339 }
340
341 public E _5() {
342 return e._1();
343 }
344
345 public F _6() {
346 return f._1();
347 }
348 };
349 }
350
351
352 /**
353 * Returns a function that returns the first element of a product.
354 *
355 * @return A function that returns the first element of a product.
356 */
357 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, A> __1() {
358 return new fj.F<P6<A, B, C, D, E, F$>, A>() {
359 public A f(final P6<A, B, C, D, E, F$> p) {
360 return p._1();
361 }
362 };
363 }
364
365 /**
366 * Returns a function that returns the second element of a product.
367 *
368 * @return A function that returns the second element of a product.
369 */
370 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, B> __2() {
371 return new fj.F<P6<A, B, C, D, E, F$>, B>() {
372 public B f(final P6<A, B, C, D, E, F$> p) {
373 return p._2();
374 }
375 };
376 }
377
378 /**
379 * Returns a function that returns the third element of a product.
380 *
381 * @return A function that returns the third element of a product.
382 */
383 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, C> __3() {
384 return new fj.F<P6<A, B, C, D, E, F$>, C>() {
385 public C f(final P6<A, B, C, D, E, F$> p) {
386 return p._3();
387 }
388 };
389 }
390
391 /**
392 * Returns a function that returns the fourth element of a product.
393 *
394 * @return A function that returns the fourth element of a product.
395 */
396 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, D> __4() {
397 return new fj.F<P6<A, B, C, D, E, F$>, D>() {
398 public D f(final P6<A, B, C, D, E, F$> p) {
399 return p._4();
400 }
401 };
402 }
403
404 /**
405 * Returns a function that returns the fifth element of a product.
406 *
407 * @return A function that returns the fifth element of a product.
408 */
409 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, E> __5() {
410 return new fj.F<P6<A, B, C, D, E, F$>, E>() {
411 public E f(final P6<A, B, C, D, E, F$> p) {
412 return p._5();
413 }
414 };
415 }
416
417 /**
418 * Returns a function that returns the sixth element of a product.
419 *
420 * @return A function that returns the sixth element of a product.
421 */
422 public static <A, B, C, D, E, F$> fj.F<P6<A, B, C, D, E, F$>, F$> __6() {
423 return new fj.F<P6<A, B, C, D, E, F$>, F$>() {
424 public F$ f(final P6<A, B, C, D, E, F$> p) {
425 return p._6();
426 }
427 };
428 }
429
430 public String toString() {
431 return Show.p6Show(Show.<A>anyShow(), Show.<B>anyShow(), Show.<C>anyShow(), Show.<D>anyShow(), Show.<E>anyShow(), Show.<F>anyShow()).showS(this);
432 }
433
434 }