Mojo function
partition
partition[: origin.set, type: CollectionElement, origin: MutableOrigin, //, cmp_fn: fn($1|1, $1|1) capturing -> Bool](span: Span[type, origin], k: Int)
Partition the input buffer inplace such that first k elements are the largest (or smallest if cmp_fn is < operator) elements. The ordering of the first k elements is undefined.
Parameters:
- type (
CollectionElement
): Type of the underlying data. - origin (
MutableOrigin
): Origin of span. - cmp_fn (
fn($1|1, $1|1) capturing -> Bool
): Comparison functor of (type, type) capturing [_] -> Bool type.
Args:
- span (
Span[type, origin]
): Input buffer. - k (
Int
): Index of the partition element.
partition[: origin.set, origin: MutableOrigin, //, cmp_fn: fn(Int, Int) capturing -> Bool](span: Span[Int, origin], k: Int)
Partition the input buffer inplace such that first k elements are the largest (or smallest if cmp_fn is < operator) elements. The ordering of the first k elements is undefined.
Parameters:
- origin (
MutableOrigin
): Origin of span. - cmp_fn (
fn(Int, Int) capturing -> Bool
): Comparison functor of (type, type) capturing [_] -> Bool type.
Args:
- span (
Span[Int, origin]
): Input buffer. - k (
Int
): Index of the partition element.
partition[: origin.set, type: DType, origin: MutableOrigin, //, cmp_fn: fn(SIMD[$1|1, 1], SIMD[$1|1, 1]) capturing -> Bool](span: Span[SIMD[type, 1], origin], k: Int)
Partition the input buffer inplace such that first k elements are the largest (or smallest if cmp_fn is < operator) elements. The ordering of the first k elements is undefined.
Parameters:
- type (
DType
): DType of the underlying data. - origin (
MutableOrigin
): Origin of span. - cmp_fn (
fn(SIMD[$1|1, 1], SIMD[$1|1, 1]) capturing -> Bool
): Comparison functor of (type, type) capturing [_] -> Bool type.
Args:
- span (
Span[SIMD[type, 1], origin]
): Input buffer. - k (
Int
): Index of the partition element.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!