mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Add documentation for functions.
This commit is contained in:
@@ -114,16 +114,38 @@ mod _bisect {
|
||||
Ok(lo)
|
||||
}
|
||||
|
||||
/// Return the index where to insert item x in list a, assuming a is sorted.
|
||||
///
|
||||
/// The return value i is such that all e in a[:i] have e < x, and all e in
|
||||
/// a[i:] have e >= x. So if x already appears in the list, a.insert(x) will
|
||||
/// insert just before the leftmost x already there.
|
||||
///
|
||||
/// Optional args lo (default 0) and hi (default len(a)) bound the
|
||||
/// slice of a to be searched.
|
||||
#[pyfunction]
|
||||
fn bisect_left(args: BisectArgs, vm: &VirtualMachine) -> PyResult<usize> {
|
||||
bisect_left_impl(args, vm)
|
||||
}
|
||||
|
||||
/// Return the index where to insert item x in list a, assuming a is sorted.
|
||||
///
|
||||
/// The return value i is such that all e in a[:i] have e <= x, and all e in
|
||||
/// a[i:] have e > x. So if x already appears in the list, a.insert(x) will
|
||||
/// insert just after the rightmost x already there.
|
||||
///
|
||||
/// Optional args lo (default 0) and hi (default len(a)) bound the
|
||||
/// slice of a to be searched.
|
||||
#[pyfunction]
|
||||
fn bisect_right(args: BisectArgs, vm: &VirtualMachine) -> PyResult<usize> {
|
||||
bisect_right_impl(args, vm)
|
||||
}
|
||||
|
||||
/// Insert item x in list a, and keep it sorted assuming a is sorted.
|
||||
///
|
||||
/// If x is already in a, insert it to the left of the leftmost x.
|
||||
///
|
||||
/// Optional args lo (default 0) and hi (default len(a)) bound the
|
||||
/// slice of a to be searched.
|
||||
#[pyfunction]
|
||||
fn insort_left(BisectArgs { a, x, lo, hi }: BisectArgs, vm: &VirtualMachine) -> PyResult {
|
||||
let index = bisect_left_impl(
|
||||
@@ -138,6 +160,12 @@ mod _bisect {
|
||||
vm.call_method(&a, "insert", (index, x))
|
||||
}
|
||||
|
||||
/// Insert item x in list a, and keep it sorted assuming a is sorted.
|
||||
///
|
||||
/// If x is already in a, insert it to the right of the rightmost x.
|
||||
///
|
||||
/// Optional args lo (default 0) and hi (default len(a)) bound the
|
||||
/// slice of a to be searched
|
||||
#[pyfunction]
|
||||
fn insort_right(BisectArgs { a, x, lo, hi }: BisectArgs, vm: &VirtualMachine) -> PyResult {
|
||||
let index = bisect_right_impl(
|
||||
|
||||
Reference in New Issue
Block a user