Skip to content

Commit fef4048

Browse files
committed
Fill in missing @param, @tparam, and @return tags in Scaladoc comments for the standard library
1 parent e715750 commit fef4048

File tree

331 files changed

+10542
-1548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

331 files changed

+10542
-1548
lines changed

library-js/src/scala/Array.scala

Lines changed: 123 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,23 @@ object Array {
6161
val emptyObjectArray = new Array[Object](0)
6262
}
6363

64-
/** Provides an implicit conversion from the Array object to a collection Factory. */
64+
/** Provides an implicit conversion from the Array object to a collection Factory.
65+
*
66+
* @tparam A the element type of the array, must have a `ClassTag`
67+
* @param dummy the `Array` companion object, used to trigger the implicit conversion
68+
*/
6569
implicit def toFactory[A : ClassTag](dummy: Array.type): Factory[A, Array[A]] = new ArrayFactory(dummy)
6670
@SerialVersionUID(3L)
6771
private class ArrayFactory[A : ClassTag](dummy: Array.type) extends Factory[A, Array[A]] with Serializable {
6872
def fromSpecific(it: IterableOnce[A]^): Array[A] = Array.from[A](it)
6973
def newBuilder: mutable.Builder[A, Array[A]] = Array.newBuilder[A]
7074
}
7175

72-
/** Returns a new [[scala.collection.mutable.ArrayBuilder]]. */
76+
/** Returns a new [[scala.collection.mutable.ArrayBuilder]].
77+
*
78+
* @tparam T the element type of the array to build
79+
* @param t the `ClassTag` for the element type, used to create the correct array type at runtime
80+
*/
7381
def newBuilder[T](implicit t: ClassTag[T]): ArrayBuilder[T] = ArrayBuilder.make[T](using t)
7482

7583
def from[A: ClassTag](it: IterableOnce[A]^): Array[A] = {
@@ -138,6 +146,11 @@ object Array {
138146
* except that this works for primitive and object arrays in a single method.
139147
*
140148
* @see `java.util.Arrays#copyOf`
149+
*
150+
* @tparam A the element type of the array
151+
* @param original the array to be copied
152+
* @param newLength the length of the copy to be returned
153+
* @return a copy of the original array, truncated or padded with default values to obtain the specified length
141154
*/
142155
def copyOf[A](original: Array[A], newLength: Int): Array[A] = (original match {
143156
case x: Array[BoxedUnit] => newUnitArray(newLength).asInstanceOf[Array[A]]
@@ -164,6 +177,12 @@ object Array {
164177
* in a single method.
165178
*
166179
* @see `java.util.Arrays#copyOf`
180+
*
181+
* @tparam A the element type of the destination array
182+
* @param original the array to be copied
183+
* @param newLength the length of the copy to be returned
184+
* @param ct the `ClassTag` for the target element type, used to create the correct array type at runtime
185+
* @return a copy of the original array, converted to type `Array[A]`, truncated or padded with default values to obtain the specified length
167186
*/
168187
def copyAs[A](original: Array[_], newLength: Int)(implicit ct: ClassTag[A]): Array[A] = {
169188
val runtimeClass = ct.runtimeClass
@@ -190,7 +209,10 @@ object Array {
190209
result
191210
}
192211

193-
/** Returns an array of length 0. */
212+
/** Returns an array of length 0.
213+
*
214+
* @tparam T the element type of the empty array
215+
*/
194216
def empty[T: ClassTag]: Array[T] = new Array[T](0)
195217

196218
/** Creates an array with given elements.
@@ -210,7 +232,11 @@ object Array {
210232
array
211233
}
212234

213-
/** Creates an array of `Boolean` objects. */
235+
/** Creates an array of `Boolean` objects.
236+
*
237+
* @param x the first element
238+
* @param xs the remaining elements
239+
*/
214240
// Subject to a compiler optimization in Cleanup, see above.
215241
def apply(x: Boolean, xs: Boolean*): Array[Boolean] = {
216242
val array = new Array[Boolean](xs.length + 1)
@@ -223,7 +249,11 @@ object Array {
223249
array
224250
}
225251

226-
/** Creates an array of `Byte` objects. */
252+
/** Creates an array of `Byte` objects.
253+
*
254+
* @param x the first element
255+
* @param xs the remaining elements
256+
*/
227257
// Subject to a compiler optimization in Cleanup, see above.
228258
def apply(x: Byte, xs: Byte*): Array[Byte] = {
229259
val array = new Array[Byte](xs.length + 1)
@@ -236,7 +266,11 @@ object Array {
236266
array
237267
}
238268

239-
/** Creates an array of `Short` objects. */
269+
/** Creates an array of `Short` objects.
270+
*
271+
* @param x the first element
272+
* @param xs the remaining elements
273+
*/
240274
// Subject to a compiler optimization in Cleanup, see above.
241275
def apply(x: Short, xs: Short*): Array[Short] = {
242276
val array = new Array[Short](xs.length + 1)
@@ -249,7 +283,11 @@ object Array {
249283
array
250284
}
251285

252-
/** Creates an array of `Char` objects. */
286+
/** Creates an array of `Char` objects.
287+
*
288+
* @param x the first element
289+
* @param xs the remaining elements
290+
*/
253291
// Subject to a compiler optimization in Cleanup, see above.
254292
def apply(x: Char, xs: Char*): Array[Char] = {
255293
val array = new Array[Char](xs.length + 1)
@@ -262,7 +300,11 @@ object Array {
262300
array
263301
}
264302

265-
/** Creates an array of `Int` objects. */
303+
/** Creates an array of `Int` objects.
304+
*
305+
* @param x the first element
306+
* @param xs the remaining elements
307+
*/
266308
// Subject to a compiler optimization in Cleanup, see above.
267309
def apply(x: Int, xs: Int*): Array[Int] = {
268310
val array = new Array[Int](xs.length + 1)
@@ -275,7 +317,11 @@ object Array {
275317
array
276318
}
277319

278-
/** Creates an array of `Long` objects. */
320+
/** Creates an array of `Long` objects.
321+
*
322+
* @param x the first element
323+
* @param xs the remaining elements
324+
*/
279325
// Subject to a compiler optimization in Cleanup, see above.
280326
def apply(x: Long, xs: Long*): Array[Long] = {
281327
val array = new Array[Long](xs.length + 1)
@@ -288,7 +334,11 @@ object Array {
288334
array
289335
}
290336

291-
/** Creates an array of `Float` objects. */
337+
/** Creates an array of `Float` objects.
338+
*
339+
* @param x the first element
340+
* @param xs the remaining elements
341+
*/
292342
// Subject to a compiler optimization in Cleanup, see above.
293343
def apply(x: Float, xs: Float*): Array[Float] = {
294344
val array = new Array[Float](xs.length + 1)
@@ -301,7 +351,11 @@ object Array {
301351
array
302352
}
303353

304-
/** Creates an array of `Double` objects. */
354+
/** Creates an array of `Double` objects.
355+
*
356+
* @param x the first element
357+
* @param xs the remaining elements
358+
*/
305359
// Subject to a compiler optimization in Cleanup, see above.
306360
def apply(x: Double, xs: Double*): Array[Double] = {
307361
val array = new Array[Double](xs.length + 1)
@@ -314,7 +368,11 @@ object Array {
314368
array
315369
}
316370

317-
/** Creates an array of `Unit` objects. */
371+
/** Creates an array of `Unit` objects.
372+
*
373+
* @param x the first element
374+
* @param xs the remaining elements
375+
*/
318376
def apply(x: Unit, xs: Unit*): Array[Unit] = {
319377
val array = new Array[Unit](xs.length + 1)
320378
array(0) = x
@@ -326,28 +384,59 @@ object Array {
326384
array
327385
}
328386

329-
/** Creates array with given dimensions. */
387+
/** Creates array with given dimensions.
388+
*
389+
* @tparam T the element type of the array
390+
* @param n1 the number of elements in the 1st dimension
391+
*/
330392
def ofDim[T: ClassTag](n1: Int): Array[T] =
331393
new Array[T](n1)
332-
/** Creates a 2-dimensional array. */
394+
/** Creates a 2-dimensional array.
395+
*
396+
* @tparam T the element type of the array
397+
* @param n1 the number of elements in the 1st dimension
398+
* @param n2 the number of elements in the 2nd dimension
399+
*/
333400
def ofDim[T: ClassTag](n1: Int, n2: Int): Array[Array[T]] = {
334401
val arr: Array[Array[T]] = (new Array[Array[T]](n1): Array[Array[T]])
335402
for (i <- 0 until n1) arr(i) = new Array[T](n2)
336403
arr
337404
// tabulate(n1)(_ => ofDim[T](n2))
338405
}
339-
/** Creates a 3-dimensional array. */
406+
/** Creates a 3-dimensional array.
407+
*
408+
* @tparam T the element type of the array
409+
* @param n1 the number of elements in the 1st dimension
410+
* @param n2 the number of elements in the 2nd dimension
411+
* @param n3 the number of elements in the 3rd dimension
412+
*/
340413
def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int): Array[Array[Array[T]]] =
341414
tabulate(n1)(_ => ofDim[T](n2, n3))
342-
/** Creates a 4-dimensional array. */
415+
/** Creates a 4-dimensional array.
416+
*
417+
* @tparam T the element type of the array
418+
* @param n1 the number of elements in the 1st dimension
419+
* @param n2 the number of elements in the 2nd dimension
420+
* @param n3 the number of elements in the 3rd dimension
421+
* @param n4 the number of elements in the 4th dimension
422+
*/
343423
def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int): Array[Array[Array[Array[T]]]] =
344424
tabulate(n1)(_ => ofDim[T](n2, n3, n4))
345-
/** Creates a 5-dimensional array. */
425+
/** Creates a 5-dimensional array.
426+
*
427+
* @tparam T the element type of the array
428+
* @param n1 the number of elements in the 1st dimension
429+
* @param n2 the number of elements in the 2nd dimension
430+
* @param n3 the number of elements in the 3rd dimension
431+
* @param n4 the number of elements in the 4th dimension
432+
* @param n5 the number of elements in the 5th dimension
433+
*/
346434
def ofDim[T: ClassTag](n1: Int, n2: Int, n3: Int, n4: Int, n5: Int): Array[Array[Array[Array[Array[T]]]]] =
347435
tabulate(n1)(_ => ofDim[T](n2, n3, n4, n5))
348436

349437
/** Concatenates all arrays into a single array.
350438
*
439+
* @tparam T the element type of the arrays
351440
* @param xss the given arrays
352441
* @return the array created from concatenating `xss`
353442
*/
@@ -367,6 +456,7 @@ object Array {
367456
* res3: Array[Double] = Array(0.365461167592537, 1.550395944913685E-4, 0.7907242137333306)
368457
* ```
369458
*
459+
* @tparam T the element type of the array
370460
* @param n the number of elements desired
371461
* @param elem the element computation
372462
* @return an Array of size n, where each element contains the result of computing
@@ -389,6 +479,7 @@ object Array {
389479
/** Returns a two-dimensional array that contains the results of some element
390480
* computation a number of times.
391481
*
482+
* @tparam T the element type of the array
392483
* @param n1 the number of elements in the 1st dimension
393484
* @param n2 the number of elements in the 2nd dimension
394485
* @param elem the element computation
@@ -399,6 +490,7 @@ object Array {
399490
/** Returns a three-dimensional array that contains the results of some element
400491
* computation a number of times.
401492
*
493+
* @tparam T the element type of the array
402494
* @param n1 the number of elements in the 1st dimension
403495
* @param n2 the number of elements in the 2nd dimension
404496
* @param n3 the number of elements in the 3rd dimension
@@ -410,6 +502,7 @@ object Array {
410502
/** Returns a four-dimensional array that contains the results of some element
411503
* computation a number of times.
412504
*
505+
* @tparam T the element type of the array
413506
* @param n1 the number of elements in the 1st dimension
414507
* @param n2 the number of elements in the 2nd dimension
415508
* @param n3 the number of elements in the 3rd dimension
@@ -422,6 +515,7 @@ object Array {
422515
/** Returns a five-dimensional array that contains the results of some element
423516
* computation a number of times.
424517
*
518+
* @tparam T the element type of the array
425519
* @param n1 the number of elements in the 1st dimension
426520
* @param n2 the number of elements in the 2nd dimension
427521
* @param n3 the number of elements in the 3rd dimension
@@ -435,9 +529,10 @@ object Array {
435529
/** Returns an array containing values of a given function over a range of integer
436530
* values starting from 0.
437531
*
532+
* @tparam T the element type of the array
438533
* @param n The number of elements in the array
439534
* @param f The function computing element values
440-
* @return A traversable consisting of elements `f(0),f(1), ..., f(n - 1)`
535+
* @return an array consisting of elements `f(0), f(1), ..., f(n - 1)`
441536
*/
442537
def tabulate[T: ClassTag](n: Int)(f: Int => T): Array[T] = {
443538
if (n <= 0) {
@@ -456,6 +551,7 @@ object Array {
456551
/** Returns a two-dimensional array containing values of a given function
457552
* over ranges of integer values starting from `0`.
458553
*
554+
* @tparam T the element type of the array
459555
* @param n1 the number of elements in the 1st dimension
460556
* @param n2 the number of elements in the 2nd dimension
461557
* @param f The function computing element values
@@ -466,6 +562,7 @@ object Array {
466562
/** Returns a three-dimensional array containing values of a given function
467563
* over ranges of integer values starting from `0`.
468564
*
565+
* @tparam T the element type of the array
469566
* @param n1 the number of elements in the 1st dimension
470567
* @param n2 the number of elements in the 2nd dimension
471568
* @param n3 the number of elements in the 3rd dimension
@@ -477,6 +574,7 @@ object Array {
477574
/** Returns a four-dimensional array containing values of a given function
478575
* over ranges of integer values starting from `0`.
479576
*
577+
* @tparam T the element type of the array
480578
* @param n1 the number of elements in the 1st dimension
481579
* @param n2 the number of elements in the 2nd dimension
482580
* @param n3 the number of elements in the 3rd dimension
@@ -489,6 +587,7 @@ object Array {
489587
/** Returns a five-dimensional array containing values of a given function
490588
* over ranges of integer values starting from `0`.
491589
*
590+
* @tparam T the element type of the array
492591
* @param n1 the number of elements in the 1st dimension
493592
* @param n2 the number of elements in the 2nd dimension
494593
* @param n3 the number of elements in the 3rd dimension
@@ -531,6 +630,7 @@ object Array {
531630

532631
/** Returns an array containing repeated applications of a function to a start value.
533632
*
633+
* @tparam T the element type of the array
534634
* @param start the start value of the array
535635
* @param len the number of elements returned by the array
536636
* @param f the function that is repeatedly applied
@@ -572,8 +672,9 @@ object Array {
572672

573673
/** Called in a pattern match like `{ case Array(x,y,z) => println('3 elements')}`.
574674
*
675+
* @tparam T the element type of the array
575676
* @param x the selector value
576-
* @return sequence wrapped in a [[scala.Some]], if `x` is an Array, otherwise `None`
677+
* @return a [[UnapplySeqWrapper]] wrapping the array for pattern matching extraction
577678
*/
578679
def unapplySeq[T](x: Array[T]): UnapplySeqWrapper[T] = new UnapplySeqWrapper(x)
579680

@@ -657,6 +758,8 @@ object Array {
657758
* @define willNotTerminateInf
658759
* @define collectExample
659760
* @define undefinedorder
761+
*
762+
* @tparam T the type of the elements in the array
660763
*/
661764
final class Array[T](_length: Int) extends java.io.Serializable with java.lang.Cloneable { self =>
662765

@@ -687,7 +790,7 @@ final class Array[T](_length: Int) extends java.io.Serializable with java.lang.C
687790

688791
/** Clones the Array.
689792
*
690-
* @return A clone of the Array.
793+
* @return a clone of the array
691794
*/
692795
override def clone(): Array[T] = throw new Error()
693796
}

0 commit comments

Comments
 (0)