From 4604ebbaaf71861a4b2f60c14812e4c22741cbac Mon Sep 17 00:00:00 2001 From: Sergey Kozlov Date: Sat, 17 Aug 2024 19:03:43 +0200 Subject: [PATCH] Refactoring --- .../scala/com/github/skozlov/algorithms/sort/MergeSort.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/scala/com/github/skozlov/algorithms/sort/MergeSort.scala b/src/main/scala/com/github/skozlov/algorithms/sort/MergeSort.scala index 08e7652..191bed7 100644 --- a/src/main/scala/com/github/skozlov/algorithms/sort/MergeSort.scala +++ b/src/main/scala/com/github/skozlov/algorithms/sort/MergeSort.scala @@ -15,8 +15,9 @@ import scala.math.Ordered.orderingToOrdered * @see * [[https://en.wikipedia.org/wiki/Merge_sort]] */ -class MergeSort[A](val smallChunkSize: Int, val smallChunkSort: FunctionalSort[A]) { - // noinspection ScalaWeakerAccess +class MergeSort[A](val smallChunkSize: Int = 5, val smallChunkSort: FunctionalSort[A] = InsertionSort()) { + require(smallChunkSize >= 0, "Negative smallChunkSize: " + smallChunkSize) + @tailrec final def merge( in1: Slice[A],