@@ -39,163 +39,220 @@ object opaques
3939 def (arr : IArray [Object ]) length : Int = arr.asInstanceOf [Array [Object ]].length
4040 def [T ](arr : IArray [T ]) length : Int = arr.asInstanceOf [Array [T ]].length
4141
42- /** All the methods on Array[T] that don't mutate in-place can be used with IArray[T].
43- */
42+ /** Returns this array concatenated with the given array. */
4443 def [T , U >: T : ClassTag ](arr : IArray [T ]) ++ (that : IArray [U ]): IArray [U ] =
4544 (genericArrayOps(arr) ++ that.asInstanceOf [Array [U ]]).asInstanceOf [IArray [U ]]
4645
46+ /** Tests whether this array contains a given value as an element. */
4747 def [T ](arr : IArray [T ]) contains(elem : T ): Boolean =
4848 genericArrayOps(arr.asInstanceOf [Array [T ]]).contains(elem)
4949
50+ /** Counts the number of elements in this array which satisfy a predicate */
5051 def [T ](arr : IArray [T ]) count(p : T => Boolean ): Int =
5152 genericArrayOps(arr).count(p)
5253
54+ /** The rest of the array without its `n` first elements. */
5355 def [T ](arr : IArray [T ]) drop(n : Int ): IArray [T ] =
5456 genericArrayOps(arr).drop(n).asInstanceOf [IArray [T ]]
5557
58+ /** The rest of the array without its `n` last elements. */
5659 def [T ](arr : IArray [T ]) dropRight(n : Int ): IArray [T ] =
5760 genericArrayOps(arr).dropRight(n).asInstanceOf [IArray [T ]]
5861
62+ /** Drops longest prefix of elements that satisfy a predicate. */
5963 def [T ](arr : IArray [T ]) dropWhile(p : T => Boolean ): IArray [T ] =
6064 genericArrayOps(arr).dropWhile(p).asInstanceOf [IArray [T ]]
6165
66+ /** Tests whether a predicate holds for at least one element of this array. */
6267 def [T ](arr : IArray [T ]) exists(p : T => Boolean ): IArray [T ] =
6368 genericArrayOps(arr).exists(p).asInstanceOf [IArray [T ]]
6469
70+ /** Selects all elements of this array which satisfy a predicate. */
6571 def [T ](arr : IArray [T ]) filter(p : T => Boolean ): IArray [T ] =
6672 genericArrayOps(arr).filter(p).asInstanceOf [IArray [T ]]
6773
74+ /** Selects all elements of this array which do not satisfy a predicate. */
6875 def [T ](arr : IArray [T ]) filterNot(p : T => Boolean ): IArray [T ] =
6976 genericArrayOps(arr).filterNot(p).asInstanceOf [IArray [T ]]
7077
78+ /** Finds the first element of the array satisfying a predicate, if any. */
7179 def [T ](arr : IArray [T ]) find(p : T => Boolean ): Option [T ] =
7280 genericArrayOps(arr).find(p)
7381
82+ /** Builds a new array by applying a function to all elements of this array
83+ * and using the elements of the resulting collections. */
7484 def [T , U : ClassTag ](arr : IArray [T ]) flatMap(f : T => IterableOnce [U ]): IArray [U ] =
7585 genericArrayOps(arr).flatMap(f).asInstanceOf [IArray [U ]]
7686
87+ /** Flattens a two-dimensional array by concatenating all its rows
88+ * into a single array. */
7789 def [T , U : ClassTag ](arr : IArray [T ]) flatten(given T => Iterable [U ]): IArray [U ] =
7890 genericArrayOps(arr).flatten.asInstanceOf [IArray [U ]]
7991
92+ /** Folds the elements of this array using the specified associative binary operator. */
8093 def [T , U >: T : ClassTag ](arr : IArray [T ]) fold(z : U )(op : (U , U ) => U ): U =
8194 genericArrayOps(arr).fold(z)(op)
8295
96+ /** Applies a binary operator to a start value and all elements of this array,
97+ * going left to right. */
8398 def [T , U : ClassTag ](arr : IArray [T ]) foldLeft(z : U )(op : (U , T ) => U ): U =
8499 genericArrayOps(arr).foldLeft(z)(op)
85100
101+ /** Applies a binary operator to all elements of this array and a start value,
102+ * going right to left. */
86103 def [T , U : ClassTag ](arr : IArray [T ]) foldRight(z : U )(op : (T , U ) => U ): U =
87104 genericArrayOps(arr).foldRight(z)(op)
88105
106+ /** Tests whether a predicate holds for all elements of this array. */
89107 def [T ](arr : IArray [T ]) forall(p : T => Boolean ): Boolean =
90108 genericArrayOps(arr).forall(p)
91109
110+ /** Apply `f` to each element for its side effects. */
92111 def [T , U ](arr : IArray [T ]) foreach(f : T => U ): Unit =
93112 genericArrayOps(arr).foreach(f)
94113
114+ /** Selects the first element of this array. */
95115 def [T ](arr : IArray [T ]) head : T =
96116 genericArrayOps(arr).head
97117
118+ /** Optionally selects the first element. */
98119 def [T ](arr : IArray [T ]) headOption : Option [T ] =
99120 genericArrayOps(arr).headOption
100121
122+ /** Finds index of first occurrence of some value in this array after or at some start index. */
101123 def [T ](arr : IArray [T ]) indexOf(elem : T , from : Int = 0 ): Int =
102124 genericArrayOps(arr.asInstanceOf [Array [T ]]).indexOf(elem, from)
103125
126+ /** Finds index of the first element satisfying some predicate after or at some start index. */
104127 def [T ](arr : IArray [T ]) indexWhere(p : T => Boolean , from : Int = 0 ): Int =
105128 genericArrayOps(arr).indexWhere(p, from)
106129
130+ /** Produces the range of all indices of this sequence. */
107131 def [T ](arr : IArray [T ]) indices : Range =
108132 genericArrayOps(arr).indices
109133
134+ /** The initial part of the array without its last element. */
110135 def [T ](arr : IArray [T ]) init : IArray [T ] =
111136 genericArrayOps(arr).init.asInstanceOf [IArray [T ]]
112137
138+ /** Tests whether the array is empty. */
113139 def [T ](arr : IArray [T ]) isEmpty : Boolean =
114140 genericArrayOps(arr).isEmpty
115141
142+ /** An iterator yielding the elemenst of this array. */
116143 def [T ](arr : IArray [T ]) iterator : Iterator [T ] =
117144 genericArrayOps(arr).iterator
118145
146+ /** Selects the last element. */
119147 def [T ](arr : IArray [T ]) last : T =
120148 genericArrayOps(arr).last
121149
150+ /** Optionally selects the last element. */
122151 def [T ](arr : IArray [T ]) lastOption : Option [T ] =
123152 genericArrayOps(arr).lastOption
124153
154+ /** Finds index of last occurrence of some value in this array before or at a given end index. */
125155 def [T ](arr : IArray [T ]) lastIndexOf(elem : T , end : Int = arr.length - 1 ): Int =
126156 genericArrayOps(arr.asInstanceOf [Array [T ]]).lastIndexOf(elem, end)
127157
158+ /** Finds index of last element satisfying some predicate before or at given end index. */
128159 def [T ](arr : IArray [T ]) lastIndexWhere(p : T => Boolean , end : Int = arr.length - 1 ): Int =
129160 genericArrayOps(arr).lastIndexWhere(p, end)
130161
162+ /** Builds a new array by applying a function to all elements of this array. */
131163 def [T , U : ClassTag ](arr : IArray [T ]) map(f : T => U ): IArray [U ] =
132164 genericArrayOps(arr).map(f).asInstanceOf [IArray [U ]]
133165
166+ /** Tests whether the array is not empty. */
134167 def [T ](arr : IArray [T ]) nonEmpty : Boolean =
135168 genericArrayOps(arr).nonEmpty
136169
170+ /** A pair of, first, all elements that satisfy predicate `p` and, second, all elements that do not. */
137171 def [T ](arr : IArray [T ]) partition(p : T => Boolean ): (IArray [T ], IArray [T ]) =
138172 genericArrayOps(arr).partition(p) match {
139173 case (x, y) => (x.asInstanceOf [IArray [T ]], y.asInstanceOf [IArray [T ]])
140174 }
141175
176+ /** Returns a new array with the elements in reversed order. */
142177 def [T ](arr : IArray [T ]) reverse : IArray [T ] =
143178 genericArrayOps(arr).reverse.asInstanceOf [IArray [T ]]
144179
180+ /** Computes a prefix scan of the elements of the array. */
145181 def [T , U >: T : ClassTag ](arr : IArray [T ]) scan(z : U )(op : (U , U ) => U ): IArray [U ] =
146182 genericArrayOps(arr).scan(z)(op).asInstanceOf [IArray [U ]]
147183
184+ /** Produces an array containing cumulative results of applying the binary
185+ * operator going left to right. */
148186 def [T , U : ClassTag ](arr : IArray [T ]) scanLeft(z : U )(op : (U , T ) => U ): IArray [U ] =
149187 genericArrayOps(arr).scanLeft(z)(op).asInstanceOf [IArray [U ]]
150188
189+ /** Produces an array containing cumulative results of applying the binary
190+ * operator going right to left. */
151191 def [T , U : ClassTag ](arr : IArray [T ]) scanRight(z : U )(op : (T , U ) => U ): IArray [U ] =
152192 genericArrayOps(arr).scanRight(z)(op).asInstanceOf [IArray [U ]]
153193
194+ /** The size of this array. */
154195 def [T ](arr : IArray [T ]) size : Int =
155196 arr.length
156197
198+ /** Selects the interval of elements between the given indices. */
157199 def [T ](arr : IArray [T ]) slice(from : Int , until : Int ): IArray [T ] =
158200 genericArrayOps(arr).slice(from, until).asInstanceOf [IArray [T ]]
159201
202+ /** Sorts this array according to the Ordering which results from transforming
203+ * an implicitly given Ordering with a transformation function. */
160204 def [T , U : ClassTag ](arr : IArray [T ]) sortBy(f : T => U )(given math .Ordering [U ]): IArray [T ] =
161205 genericArrayOps(arr).sortBy(f).asInstanceOf [IArray [T ]]
162206
207+ /** Sorts this array according to a comparison function. */
163208 def [T ](arr : IArray [T ]) sortWith(f : (T , T ) => Boolean ): IArray [T ] =
164209 genericArrayOps(arr).sortWith(f).asInstanceOf [IArray [T ]]
165210
211+ /** Sorts this array according to an Ordering. */
166212 def [T ](arr : IArray [T ]) sorted(given math .Ordering [T ]): IArray [T ] =
167213 genericArrayOps(arr).sorted.asInstanceOf [IArray [T ]]
168214
215+ /** Splits this array into a prefix/suffix pair according to a predicate. */
169216 def [T ](arr : IArray [T ]) span(p : T => Boolean ): (IArray [T ], IArray [T ]) =
170217 genericArrayOps(arr).span(p) match {
171218 case (x, y) => (x.asInstanceOf [IArray [T ]], y.asInstanceOf [IArray [T ]])
172219 }
173220
221+ /** Splits this array into two at a given position. */
174222 def [T ](arr : IArray [T ]) splitAt(n : Int ): (IArray [T ], IArray [T ]) =
175223 genericArrayOps(arr).splitAt(n) match {
176224 case (x, y) => (x.asInstanceOf [IArray [T ]], y.asInstanceOf [IArray [T ]])
177225 }
178226
227+ /** Tests whether this array starts with the given array. */
179228 def [T , U >: T : ClassTag ](arr : IArray [T ]) startsWith(that : IArray [U ], offset : Int = 0 ): Boolean =
180229 genericArrayOps(arr).startsWith(that.asInstanceOf [Array [U ]])
181230
231+ /** The rest of the array without its first element. */
182232 def [T ](arr : IArray [T ]) tail : IArray [T ] =
183233 genericArrayOps(arr).tail.asInstanceOf [IArray [T ]]
184234
235+ /** An array containing the first `n` elements of this array. */
185236 def [T ](arr : IArray [T ]) take(n : Int ): IArray [T ] =
186237 genericArrayOps(arr).take(n).asInstanceOf [IArray [T ]]
187238
239+ /** An array containing the last `n` elements of this array. */
188240 def [T ](arr : IArray [T ]) takeRight(n : Int ): IArray [T ] =
189241 genericArrayOps(arr).takeRight(n).asInstanceOf [IArray [T ]]
190242
243+ /** Takes longest prefix of elements that satisfy a predicate. */
191244 def [T ](arr : IArray [T ]) takeWhile(p : T => Boolean ): IArray [T ] =
192245 genericArrayOps(arr).takeWhile(p).asInstanceOf [IArray [T ]]
193246
247+ /** Converts an array of pairs into an array of first elements and an array of second elements. */
194248 def [U : ClassTag , V : ClassTag ](arr : IArray [(U , V )]) unzip : (IArray [U ], IArray [V ]) =
195249 genericArrayOps(arr).unzip match {
196250 case (x, y) => (x.asInstanceOf [IArray [U ]], y.asInstanceOf [IArray [V ]])
197251 }
198252
253+ /** Returns an array formed from this array and another iterable collection
254+ * by combining corresponding elements in pairs.
255+ * If one of the two collections is longer than the other, its remaining elements are ignored. */
199256 def [T , U : ClassTag ](arr : IArray [T ]) zip(that : IArray [U ]): IArray [(T , U )] =
200257 genericArrayOps(arr).zip(that).asInstanceOf [IArray [(T , U )]]
201258end opaques
0 commit comments