Re: how to avoid repetition?
| From: | graeme | Date: | Fri, 10 Jun 2005 02:31:45 +0000 |
| Subject: | Re: how to avoid repetition? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-26087@lists.php.net to get a copy of this message | ||
A couple of ideas to improve the chances of generating unique strings
You could create 20,000,001 char(6) strings, merge the first with the last, second with the second last and so on, creating char(12) strings
or
You could create 20,000,001 char(7) strings, merge the first with the last, second with the second last and so on, creating char(14) strings and then dropping two digits at random.
BUT if you must guarantee that the strings are unique then you will need to do a comparison of the resulting strings. Using a database to sort and then compare is as good an approach as any, since database have good sorting algorithms and are designed to manage large numbers.
graeme.
bo wrote:
I need to generate 10million 12-char string and I am able to do so, however the problem is how to avoid repetition keeping each string unique? it will be a disaster to compare each string,isn't it? ps Thanks Yong. Bo-- Experience is a good teacher, but she sends in terrific bills. Minna Antrim