Skip to content

Commit

Permalink
Merge pull request #58 from larsmans/order-statistic-doc
Browse files Browse the repository at this point in the history
document use of sortedlist and sortedset as order statistic DSs
  • Loading branch information
DanielStutzbach committed Mar 12, 2014
2 parents ca054a2 + 1b2a7c6 commit 1823f50
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/sortedlist.rst
Expand Up @@ -26,6 +26,10 @@ sortedlist
*key* function must always return the same key for an item or the
results are unpredictable.

A :class:`sortedlist` can be used as an order statistic tree
(Cormen *et al.*, *Introduction to Algorithms*, ch. 14)
that allows duplicate keys.

.. method:: x in L

Returns True if and only if *x* is an element in the list.
Expand Down Expand Up @@ -67,6 +71,8 @@ sortedlist
|theta(1)| operations if the list's size has not been changed
recently. Requires no comparisons in any case.

(Cormen *et al.* call this operation "SELECT".)

:rtype: item

.. method:: L[i:j]
Expand Down Expand Up @@ -198,6 +204,8 @@ sortedlist
In the worst case, requires |theta(log**2 m)| operations and
|theta(log m)| comparisons, where *m* is *stop* - *start*.

(Cormen *et al.* call this operation "RANK".)

:rtype: :class:`int`

.. method:: L.pop([index])
Expand Down
7 changes: 7 additions & 0 deletions doc/sortedset.rst
Expand Up @@ -23,6 +23,9 @@ sortedset
Unlike a :class:`set`, a :class:`sortedset` does not require items
to be hashable.

A :class:`sortedset` can be used as an order statistic tree
(Cormen *et al.*, *Introduction to Algorithms*, ch. 14).

.. method:: x in S

Returns True if and only if *x* is an element in the set.
Expand Down Expand Up @@ -74,6 +77,8 @@ sortedset
|theta(1)| operations if the set's size has not been changed
recently. Requires no comparisons in any case.

(Cormen *et al.* call this operation "SELECT".)

:rtype: item

.. method:: S[i:j]
Expand Down Expand Up @@ -224,6 +229,8 @@ sortedset
In the worst case, requires |theta(log**2 m)| operations and
|theta(log m)| comparisons, where *m* is *stop* - *start*.

(Cormen *et al.* call this operation "RANK".)

:rtype: :class:`int`

.. method:: S.intersection(S2, ...)
Expand Down

0 comments on commit 1823f50

Please sign in to comment.