I need to generate 'random' int values that will be used as array indexes so they need to be uniqe for given interval.
LFSR seems to be perfect for this task but theres a catch: either array size ought to have size 2^n (in some cases it forces to allocate much more memory than required one(eg. data size 2100 - array size 4096)) or to skip generated numbers until proper value is found (waste of LFSR capabilities, in some cases generation time of index can be noticeable).
I have tried to create some formula to compute array indexes but I've failed, especially for small (<120) array sizes.
Is there any optimal (in terms of resources and computing time) solution to this problem?
Thanks in advance for answers!