@@ -141,115 +141,6 @@ module Array =
141141 let items ' = Array.copy items
142142 quickSelectInPlaceWith 0 ( items'.Length - 1 ) k items'
143143
144-
145-
146- ///Old partitionSortInPlace fails with dublicates
147-
148- ///// Arranges the items between the left and right border, that all items left of the pivot element are smaller and bigger on the right.
149- ///// Function works in place and returns the index of the pivote element
150- //let partitionSortInPlace left right (items:array<'T>) =
151-
152- // // http://blog.mischel.com/2011/10/25/when-theory-meets-practice/
153- // // Median of three optimization improves performance in general,
154- // // and eliminates worst-case behavior for sorted or reverse-sorted data.
155- // let center = (right + left) / 2
156- // if (items.[left] > items.[right]) then
157- // swapInPlace left right items
158- // if (items.[center] < items.[left]) then
159- // swapInPlace center left items
160- // if (items.[center] > items.[right]) then
161- // swapInPlace center right items
162- // // // pick the pivot point and save it
163- // let pivot = items.[center]
164-
165- // let rec moveRightIndex i j =
166- // if (pivot < items.[j]) && (i < j) then
167- // moveRightIndex i (j-1)
168- // else
169- // j
170-
171- // let rec moveLeftIndex i j =
172- // if (items.[i] <= pivot) && (i < j) then
173- // moveLeftIndex (i+1) j
174- // else
175- // i
176-
177- // let rec loop i j =
178- // if (i < j) then
179- // let j' = moveRightIndex i j
180- // let i' = moveLeftIndex i j'
181- // if i'=i && j'=j then // experimental to avoid: nan compare always false
182- // -1
183- // else
184- // if i' < j' then swapInPlace i' j' items
185- // loop i' j'
186- // else
187- // i
188-
189- // let i = loop left right
190- // i
191-
192-
193- ///// Finds the kth smallest element in an unordered array
194- //let inline quickSelect k (items:array<'T>) =
195- // let zero = LanguagePrimitives.GenericZero< 'T >
196-
197- // let rec quickSelect' (items:array<'T>) left right k =
198-
199- // // get pivot position
200- // let pivot = partitionSortInPlace left right items
201- // if pivot >= 0 then
202- // // if pivot is less than k, select from the right part
203- // if (pivot < k) then
204- // quickSelect' items (pivot + 1) right k
205- // // if pivot is greater than k, select from the left side
206- // elif (pivot > k) then
207- // quickSelect' items left (pivot - 1) k
208- // // if equal, return the value
209- // else
210- // items.[pivot]
211- // else
212- // zero / zero
213-
214- // let k' = k - 1
215- // if k' <= 0 then
216- // Array.min items
217- // elif k' > items.Length-1 then
218- // Array.max items
219- // else
220- // let items' = Array.copy items
221- // quickSelect' items' 0 (items'.Length - 1) k'
222-
223-
224- ///// Finds the kth smallest element in an unordered array
225- ///// Works in place and can change the order of the elements in the input array
226- //let inline quickSelectInPlace k (items:array<'T>) : 'T =
227- // let zero = LanguagePrimitives.GenericZero< 'T >
228-
229- // let rec quickSelect' (items:array<'T>) left right k =
230- // // get pivot position
231- // let pivot = partitionSortInPlace left right items
232- // if pivot >= 0 then
233- // // if pivot is less than k, select from the right part
234- // if (pivot < k) then
235- // quickSelect' items (pivot + 1) right k
236- // // if pivot is greater than k, select from the left side
237- // elif (pivot > k) then
238- // quickSelect' items left (pivot - 1) k
239- // // if equal, return the value
240- // else
241- // items.[pivot]
242- // else
243- // zero / zero
244-
245- // let k' = k - 1
246- // if k' <= 0 then
247- // Array.min items
248- // elif k' > items.Length-1 then
249- // Array.max items
250- // else
251- // quickSelect' items 0 (items.Length - 1) k'
252-
253144 /// <summary >Computes the Weighted Mean</summary >
254145 /// <remarks ></remarks >
255146 /// <param name =" weights " ></param >
0 commit comments