- Preparing search index...
- The search index is not available
feng3d
Methods
Static
binarySearch
- binarySearch<T>(array: T[], target: T, compare: ((a: T, b: T) => number), start?: number, end?: number): number
-
Parameters
-
array: T[]
-
target: T
-
compare: ((a: T, b: T) => number)
-
- (a: T, b: T): number
-
Returns number
-
Optional
start: number
-
Optional
end: number
Returns number
Static
binarySearchInsert
- binarySearchInsert<T>(array: T[], target: T, compare: ((a: T, b: T) => number), start?: number, end?: number): number
-
Parameters
-
array: T[]
-
target: T
-
compare: ((a: T, b: T) => number)
-
- (a: T, b: T): number
-
Returns number
-
Optional
start: number
-
Optional
end: number
Returns number
Static
create
- create<T>(length: number, itemFunc: ((index: number) => T)): T[]
-
Parameters
-
length: number
-
itemFunc: ((index: number) => T)
-
- (index: number): T
-
Returns T
Returns T[]
Static
deleteItem
- deleteItem<T>(array: T[], item: T): number
-
Returns number
Static
equal
- equal<T>(array: T[], arr: ArrayLike<T>): boolean
-
Parameters
-
array: T[]
-
arr: ArrayLike<T>
Returns boolean
Static
isUnique
- isUnique<T>(array: T[], compare?: ((a: T, b: T) => boolean)): boolean
-
Parameters
-
array: T[]
-
compare: ((a: T, b: T) => boolean) = ...
-
- (a: T, b: T): boolean
-
Returns boolean
Returns boolean
Static
replace
- replace<T>(array: T[], a: T, b: T, isAdd?: boolean): T[]
-
Parameters
-
array: T[]
-
a: T
-
b: T
-
isAdd: boolean = true
Returns T[]
Static
unique
- unique<T>(array: T[], compare?: ((a: T, b: T) => boolean)): T[]
-
Parameters
-
array: T[]
-
compare: ((a: T, b: T) => boolean) = ...
-
- (a: T, b: T): boolean
-
Returns boolean
Returns T[]
二分查找,如果有多个则返回第一个
Returns
查找到目标时返回所在位置,否则返回-1