mς
­fIc           @   s   d  Z  d d d  Z e Z d d d  Z e Z d d d  Z d d d  Z y/ d k l Z l Z l Z l Z l Z l Z Wn e	 j
 o n Xd S(   s   Bisection algorithms.i    c         C   sy   | d j o t |   } n xE | | j  o7 | | d } | |  | j  o
 | } q  | d } q  W|  i | |  d S(   sο   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.
    i   i   N(   t   hit   Nonet   lent   at   lot   midt   xt   insert(   R   R   R   R    R   (    (    t#   /mit/python/lib/python2.4/bisect.pyt   insort_right   s       
c         C   si   | d j o t |   } n xE | | j  o7 | | d } | |  | j  o
 | } q  | d } q  W| S(   sr  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, i points just
    beyond the rightmost x already there.

    Optional args lo (default 0) and hi (default len(a)) bound the
    slice of a to be searched.
    i   i   N(   R    R   R   R   R   R   R   (   R   R   R   R    R   (    (    R   t   bisect_right   s    	   
c         C   sy   | d j o t |   } n xE | | j  o7 | | d } |  | | j  o | d } q  | } q  W|  i | |  d S(   sν   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.
    i   i   N(   R    R   R   R   R   R   R   R   (   R   R   R   R    R   (    (    R   t   insort_left+   s       c         C   si   | d j o t |   } n xE | | j  o7 | | d } |  | | j  o | d } q  | } q  W| S(   sq  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, i points 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.
    i   i   N(   R    R   R   R   R   R   R   (   R   R   R   R    R   (    (    R   t   bisect_left=   s    	   (   s   bisect_rights   bisect_lefts   insort_lefts   insort_rights   insorts   bisectN(
   t   __doc__R   R	   t   insortR
   t   bisectR   R   t   _bisectt   ImportError(   R	   R   R   R   R   R
   (    (    R   t   ?   s   /