|
Last change
on this file since 30 was
29,
checked in by landauf, 17 years ago
|
|
updated boost from 1_33_1 to 1_34_1
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | # Copyright David Abrahams 2004. Distributed under the Boost |
|---|
| 2 | # Software License, Version 1.0. (See accompanying |
|---|
| 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 4 | ''' |
|---|
| 5 | >>> from iterator_ext import * |
|---|
| 6 | >>> from input_iterator import * |
|---|
| 7 | >>> x = list_int() |
|---|
| 8 | >>> x.push_back(1) |
|---|
| 9 | >>> x.back() |
|---|
| 10 | 1 |
|---|
| 11 | >>> x.push_back(3) |
|---|
| 12 | >>> x.push_back(5) |
|---|
| 13 | >>> for y in x: |
|---|
| 14 | ... print y |
|---|
| 15 | 1 |
|---|
| 16 | 3 |
|---|
| 17 | 5 |
|---|
| 18 | >>> z = range(x) |
|---|
| 19 | >>> for y in z: |
|---|
| 20 | ... print y |
|---|
| 21 | 1 |
|---|
| 22 | 3 |
|---|
| 23 | 5 |
|---|
| 24 | |
|---|
| 25 | Range2 wraps a transform_iterator which doubles the elements it |
|---|
| 26 | traverses. This proves we can wrap input iterators |
|---|
| 27 | |
|---|
| 28 | >>> z2 = range2(x) |
|---|
| 29 | >>> for y in z2: |
|---|
| 30 | ... print y |
|---|
| 31 | 2 |
|---|
| 32 | 6 |
|---|
| 33 | 10 |
|---|
| 34 | |
|---|
| 35 | >>> l2 = two_lists() |
|---|
| 36 | >>> for y in l2.primes: |
|---|
| 37 | ... print y |
|---|
| 38 | 2 |
|---|
| 39 | 3 |
|---|
| 40 | 5 |
|---|
| 41 | 7 |
|---|
| 42 | 11 |
|---|
| 43 | 13 |
|---|
| 44 | >>> for y in l2.evens: |
|---|
| 45 | ... print y |
|---|
| 46 | 2 |
|---|
| 47 | 4 |
|---|
| 48 | 6 |
|---|
| 49 | 8 |
|---|
| 50 | 10 |
|---|
| 51 | 12 |
|---|
| 52 | >>> ll = list_list() |
|---|
| 53 | >>> ll.push_back(x) |
|---|
| 54 | >>> x.push_back(7) |
|---|
| 55 | >>> ll.push_back(x) |
|---|
| 56 | >>> for a in ll: |
|---|
| 57 | ... for b in a: |
|---|
| 58 | ... print b, |
|---|
| 59 | ... print |
|---|
| 60 | ... |
|---|
| 61 | 1 3 5 |
|---|
| 62 | 1 3 5 7 |
|---|
| 63 | ''' |
|---|
| 64 | def run(args = None): |
|---|
| 65 | import sys |
|---|
| 66 | import doctest |
|---|
| 67 | |
|---|
| 68 | if args is not None: |
|---|
| 69 | sys.argv = args |
|---|
| 70 | return doctest.testmod(sys.modules.get(__name__)) |
|---|
| 71 | |
|---|
| 72 | if __name__ == '__main__': |
|---|
| 73 | print "running..." |
|---|
| 74 | import sys |
|---|
| 75 | status = run()[0] |
|---|
| 76 | if (status == 0): print "Done." |
|---|
| 77 | sys.exit(status) |
|---|
Note: See
TracBrowser
for help on using the repository browser.