diff options
| author | aozima <[email protected]> | 2013-02-22 13:54:15 +0800 |
|---|---|---|
| committer | aozima <[email protected]> | 2013-02-22 13:54:15 +0800 |
| commit | 8a8f904e1b6239b895fe97a63eaad62cdef67f61 (patch) | |
| tree | 893d8026dedf827fbb060da91dff504b7cb6d300 /components/rtgui/utils/perfect_hash/example-Python/PerfHash.py | |
| parent | 8421ecfa277eeb813e7c217955328c6329208f38 (diff) | |
| parent | 4e7247e072e9b298a8811e5db9041558fb5e7c68 (diff) | |
Merge branch 'master' into aozima
Conflicts:
bsp/stm32f107/project.uvproj
Diffstat (limited to 'components/rtgui/utils/perfect_hash/example-Python/PerfHash.py')
| -rw-r--r-- | components/rtgui/utils/perfect_hash/example-Python/PerfHash.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/components/rtgui/utils/perfect_hash/example-Python/PerfHash.py b/components/rtgui/utils/perfect_hash/example-Python/PerfHash.py deleted file mode 100644 index 49131c2b63..0000000000 --- a/components/rtgui/utils/perfect_hash/example-Python/PerfHash.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -""" -This example shows how to use the class PerfHash. - -This class is designed for creating perfect hash tables at run time, -which should be avoided, in particulat inserting new keys is -prohibitively expensive since a new perfect hash table needs to be -constructed. However, this class can be usefull for testing. - -For practical programming purposes in Python the class PerfHash -should never be used because Python's built-in dictionary is very -efficient and always faster than PerfHash. -""" - -import sys - -sys.path.append('..') -from perfect_hash import PerfHash - - -month = dict(zip('jan feb mar apr may jun jul aug sep oct mov dec'.split(), - range(1, 13))) - -d = PerfHash(month) - - -for m in month: - assert month[m] == d[m] - -d[True] = False - -assert d[True] == False - -for i in xrange(10): # very expensive - d[i] = 2*i*i + 3*i -7 - -assert d[4] == 37 - - -print 'OK' |
