I need to generate random numbers in the range 1 - 10000 continuously with out duplication. Any recommendations?
Description: we are building a new version for our application, which maintains records in Sqlite DB. in the last version of our application, we did not had unique key for each record. But now with new upgraded version, we need to support the import facility from the last version's DB. So what we do is, we read each and every record from the old DB and generate a random number for the unique key and store it in new DB. Here we many need to import up to 10000 records continuously.
TR1 has good random number support - if your compiler supports it.
Otherwise Boost
It's basically what became TR1.
As far as not getting duplicates - you want a shuffle. It can be pretty simple, but there are some pitfalls if you don't do it right. Jeff Atwood did a nice write up a while back:
http://www.codinghorror.com/blog/archives/001015.html
Numerical Recipes in C has a whole chapter dedicated to random number generation. There are a few implementation there. From simple and straight forward to complex with good statistical properties.