-
Notifications
You must be signed in to change notification settings - Fork 587
/
primitiveList.stg
178 lines (149 loc) · 4.65 KB
/
primitiveList.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import "copyrightAndOthers.stg"
import "primitiveEquals.stg"
import "primitiveHashCode.stg"
import "primitiveAPI.stg"
import "primitiveLiteral.stg"
targetPath() ::= "org/eclipse/collections/api/list/primitive"
fileName(primitive) ::= "<primitive.name>List"
class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>
body(type, name) ::= <<
<copyrightAndOthers()>
package org.eclipse.collections.api.list.primitive;
import org.eclipse.collections.api.<name>Iterable;
import org.eclipse.collections.api.block.function.primitive.<name>IntToObjectFunction;
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.list.ListIterable;
import org.eclipse.collections.api.ordered.primitive.Reversible<name>Iterable;
import org.eclipse.collections.api.tuple.primitive.<name><name>Pair;
import org.eclipse.collections.api.tuple.primitive.<name>ObjectPair;
<if(primitive.specializedStream)>
import java.util.Spliterator;
import java.util.stream.StreamSupport;
import java.util.stream.<name>Stream;
<endif>
/**
* This file was automatically generated from template file primitiveList.stg.
*
* @since 3.0.
*/
public interface <name>List extends Reversible<name>Iterable
{
<type> get(int index);
<(arithmeticMethods.(type))(name, type)>
int lastIndexOf(<type> value);
<sharedAPI(fileName(primitive), name)>
/**
* @since 9.0.
*/
@Override
default <name>List tap(<name>Procedure procedure)
{
this.forEach(procedure);
return this;
}
@Override
\<V> ListIterable\<V> collect(<name>ToObjectFunction\<? extends V> function);
/**
* Returns a new ListIterable using results obtained by applying the specified function to each element
* and its corresponding index.
*
* @since 9.1.
*/
@Override
default \<V> ListIterable\<V> collectWithIndex(<name>IntToObjectFunction\<? extends V> function)
{
int[] index = { 0 };
return this.collect(each -> function.value(each, index[0]++));
}
/**
* Follows the same general contract as {@link java.util.List#equals(Object)}.
*/
@Override
boolean equals(Object o);
/**
* Follows the same general contract as {@link java.util.List#hashCode()}.
*/
@Override
int hashCode();
/**
* Returns an immutable copy of this list. If the list is immutable, it returns itself.
*/
Immutable<name>List toImmutable();
/**
* @since 6.0.
*/
@Override
<name>List distinct();
/**
* @since 5.0.
*/
@Override
<name>List toReversed();
/**
* @see java.util.List#subList(int fromIndex, int toIndex)
* @since 5.0.
*/
<name>List subList(int fromIndex, int toIndex);
/**
* Returns a {@code ListIterable} formed from this {@code <name>List} and another {@code <name>List} by
* combining corresponding elements in pairs. If one of the two {@code <name>List}s is longer than the other, its
* remaining elements are ignored.
*
* @since 9.1.
*/
default ListIterable\<<name><name>Pair> zip<name>(<name>Iterable iterable)
{
throw new UnsupportedOperationException("Default method to prevent breaking backwards compatibility");
}
/**
* Returns a {@code ListIterable} formed from this {@code <name>List} and a {@code ListIterable} by
* combining corresponding elements in pairs. If one of the two Lists is longer than the other, its
* remaining elements are ignored.
*
* @since 9.1.
*/
default \<T> ListIterable\<<name>ObjectPair\<T\>> zip(Iterable\<T> iterable)
{
throw new UnsupportedOperationException("Default method to prevent breaking backwards compatibility");
}
<if(primitive.specializedStream)>
/**
* @since 10.0
*/
Spliterator.Of<name> spliterator();
/**
* @since 10.0
*/
default <name>Stream primitiveStream()
{
return StreamSupport.<type>Stream(this.spliterator(), false);
}
/**
* @since 10.0
*/
default <name>Stream primitiveParallelStream()
{
return StreamSupport.<type>Stream(this.spliterator(), true);
}
<endif>
}
>>
arithmeticMethods ::= [
"byte": "allMethods",
"short": "allMethods",
"char": "allMethods",
"int": "allMethods",
"long": "allMethods",
"float": "allMethods",
"double": "allMethods",
"boolean": "noMethods"
]
allMethods(name, type) ::=<<
<wideType.(type)> dotProduct(<name>List list);
int binarySearch(<type> value);
>>
noMethods(name, type) ::= ""