summaryrefslogtreecommitdiff
path: root/components/rtgui/utils/perfect_hash/example-Python/generate_hash.py
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2013-02-21 13:11:10 +0800
committerBernard Xiong <[email protected]>2013-02-21 13:11:10 +0800
commit385f682d7bfce81ba281faaffb0a250ab94985b8 (patch)
tree94fca413db98390d21dc18938067a7a90e470a6f /components/rtgui/utils/perfect_hash/example-Python/generate_hash.py
parentc4bd0023f8da136c5788f47f9a0170a77f627be9 (diff)
remove RT-Thread GUI from RT-Thread temporary
Diffstat (limited to 'components/rtgui/utils/perfect_hash/example-Python/generate_hash.py')
-rw-r--r--components/rtgui/utils/perfect_hash/example-Python/generate_hash.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/components/rtgui/utils/perfect_hash/example-Python/generate_hash.py b/components/rtgui/utils/perfect_hash/example-Python/generate_hash.py
deleted file mode 100644
index dfe9f92186..0000000000
--- a/components/rtgui/utils/perfect_hash/example-Python/generate_hash.py
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/usr/bin/env python
-"""
-This example shows how to use the function generate_hash.
-
-generate_hash(kdic, Hash)
-
-returns hash functions f1 and f2, and G for a perfect minimal hash.
-Input is dictionary 'kdic' with the keys and desired hash values.
-'Hash' is a random hash function generator, that means Hash(N) returns a
-returns a random hash function which returns hash values from 0..N-1.
-"""
-
-import sys
-import random, string
-
-sys.path.append('..')
-from perfect_hash import generate_hash
-
-
-
-month = dict(zip('jan feb mar apr may jun jul aug sep oct mov dec'.split(),
- range(1, 13)))
-
-def mkRandHash(N):
- """
- Return a random hash function which returns hash values from 0..N-1.
- """
- junk = "".join(random.choice(string.letters + string.digits)
- for i in xrange(10))
- return lambda key: hash(junk + str(key)) % N
-
-
-f1, f2, G = generate_hash(month, mkRandHash)
-
-for k, h in month.items():
- assert h == ( G[f1(k)] + G[f2(k)] ) % len(G)
-
-print 'OK'