Skip to content

KBE3D / KBCore / Cesium / mergeSort

函数: mergeSort()

mergeSort(array: any[] | Float32Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>, comparator: mergeSortComparator, userDefinedObject?: any): void

A stable merge sort.

参数

array

The array to sort.

any[] | Float32Array<ArrayBufferLike> | Int8Array<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | Int16Array<ArrayBufferLike> | Uint16Array<ArrayBufferLike> | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike> | Float64Array<ArrayBufferLike>

comparator

mergeSortComparator

The function to use to compare elements in the array.

userDefinedObject?

any

Any item to pass as the third parameter to <code>comparator</code>.

返回

void

示例

ts
// Assume array contains BoundingSpheres in world coordinates.
// Sort them in ascending order of distance from the camera.
const position = camera.positionWC;
Cesium.mergeSort(array, function(a, b, position) {
    return Cesium.BoundingSphere.distanceSquaredTo(b, position) - Cesium.BoundingSphere.distanceSquaredTo(a, position);
}, position);

KBE3D @3.0.0 Copyright © 2024-present KBE3D