source: trunk/essentials/dev-lang/python/Doc/lib/libbisect.tex@ 3226

Last change on this file since 3226 was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 3.1 KB
Line 
1\section{\module{bisect} ---
2 Array bisection algorithm}
3
4\declaremodule{standard}{bisect}
5\modulesynopsis{Array bisection algorithms for binary searching.}
6\sectionauthor{Fred L. Drake, Jr.}{[email protected]}
7% LaTeX produced by Fred L. Drake, Jr. <[email protected]>, with an
8% example based on the PyModules FAQ entry by Aaron Watters
9% <[email protected]>.
10
11
12This module provides support for maintaining a list in sorted order
13without having to sort the list after each insertion. For long lists
14of items with expensive comparison operations, this can be an
15improvement over the more common approach. The module is called
16\module{bisect} because it uses a basic bisection algorithm to do its
17work. The source code may be most useful as a working example of the
18algorithm (the boundary conditions are already right!).
19
20The following functions are provided:
21
22\begin{funcdesc}{bisect_left}{list, item\optional{, lo\optional{, hi}}}
23 Locate the proper insertion point for \var{item} in \var{list} to
24 maintain sorted order. The parameters \var{lo} and \var{hi} may be
25 used to specify a subset of the list which should be considered; by
26 default the entire list is used. If \var{item} is already present
27 in \var{list}, the insertion point will be before (to the left of)
28 any existing entries. The return value is suitable for use as the