-
Notifications
You must be signed in to change notification settings - Fork 614
/
primitiveIterable.stg
148 lines (106 loc) · 3.96 KB
/
primitiveIterable.stg
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import "copyright.stg"
import "primitiveLiteral.stg"
targetPath() ::= "org/eclipse/collections/api"
fileName(primitive) ::= "<primitive.name>Iterable"
class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>
body(type, name) ::= <<
<copyright()>
package org.eclipse.collections.api;
<(wideStatisticsImport.(type))>
import org.eclipse.collections.api.bag.primitive.Mutable<name>Bag;
import org.eclipse.collections.api.block.function.primitive.Object<name>ToObjectFunction;
import org.eclipse.collections.api.block.function.primitive.<name>ToObjectFunction;
import org.eclipse.collections.api.block.predicate.primitive.<name>Predicate;
import org.eclipse.collections.api.block.procedure.primitive.<name>Procedure;
import org.eclipse.collections.api.iterator.<name>Iterator;
import org.eclipse.collections.api.list.primitive.Mutable<name>List;
import org.eclipse.collections.api.set.primitive.Mutable<name>Set;
/**
* <name>Iterable is an interface which is memory-optimized for <type> primitives.
* It is inspired by the interface RichIterable, and contains a subset of the internal iterator methods on RichIterable like collect, sum, etc.
* The API also includes an external iterator method, which returns an <name>Iterator. <name>Iterator helps iterate over the <name>Iterable without boxing the primitives.
* This file was automatically generated from template file primitiveIterable.stg.
*/
public interface <name>Iterable extends PrimitiveIterable
{
<name>Iterator <type>Iterator();
<type>[] toArray();
boolean contains(<type> value);
boolean containsAll(<type>... source);
boolean containsAll(<name>Iterable source);
void forEach(<name>Procedure procedure);
/**
* @since 7.0.
*/
void each(<name>Procedure procedure);
<name>Iterable select(<name>Predicate predicate);
<name>Iterable reject(<name>Predicate predicate);
\<V> RichIterable\<V> collect(<name>ToObjectFunction\<? extends V> function);
<type> detectIfNone(<name>Predicate predicate, <type> ifNone);
int count(<name>Predicate predicate);
boolean anySatisfy(<name>Predicate predicate);
boolean allSatisfy(<name>Predicate predicate);
boolean noneSatisfy(<name>Predicate predicate);
Mutable<name>List toList();
Mutable<name>Set toSet();
Mutable<name>Bag toBag();
Lazy<name>Iterable asLazy();
\<T> T injectInto(T injectedValue, Object<name>ToObjectFunction\<? super T, ? extends T> function);
<(arithmeticMethods.(type))()>
}
>>
arithmeticMethods ::= [
"byte": "allMethods",
"short": "allMethods",
"char": "allMethods",
"int": "allMethods",
"long": "allMethods",
"float": "allMethods",
"double": "allMethods",
"boolean": "noMethods"
]
allMethods() ::= <<
<\n>
<(wideType.(type))> sum();
/**
* @since 8.0
*/
default <(wideStatistics.(type))> summaryStatistics()
{
<(wideStatistics.(type))> stats = new <(wideStatistics.(type))>();
this.forEach(stats::accept);
return stats;
}
<type> max();
<type> maxIfEmpty(<type> defaultValue);
<type> min();
<type> minIfEmpty(<type> defaultValue);
double average();
double median();
<type>[] toSortedArray();
Mutable<name>List toSortedList();
>>
noMethods() ::= ""
wideStatistics ::= [
"byte": "IntSummaryStatistics",
"short": "IntSummaryStatistics",
"char": "IntSummaryStatistics",
"int": "IntSummaryStatistics",
"long": "LongSummaryStatistics",
"float": "DoubleSummaryStatistics",
"double": "DoubleSummaryStatistics",
default: "no matching wide type"
]
wideStatisticsImport ::= [
"boolean": "",
"byte": "import java.util.IntSummaryStatistics;",
"short": "import java.util.IntSummaryStatistics;",
"char": "import java.util.IntSummaryStatistics;",
"int": "import java.util.IntSummaryStatistics;",
"long": "import java.util.LongSummaryStatistics;",
"float": "import java.util.DoubleSummaryStatistics;",
"double": "import java.util.DoubleSummaryStatistics;",
default: "no matching wide type"
]