Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/python/test/iterator.py @ 29

Last change on this file since 29 was 29, checked in by landauf, 16 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()
101
11>>> x.push_back(3)
12>>> x.push_back(5)
13>>> for y in x:
14...     print y
151
163
175
18>>> z = range(x)
19>>> for y in z:
20...     print y
211
223
235
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
312
326
3310
34
35>>> l2 = two_lists()
36>>> for y in l2.primes:
37...     print y
382
393
405
417
4211
4313
44>>> for y in l2.evens:
45...     print y
462
474
486
498
5010
5112
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...
611 3 5
621 3 5 7
63'''
64def 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   
72if __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.