note 82022 added to function.mt-rand
| From: | guilhem at dublin dot ie | Date: | Tue, 25 Mar 2008 09:09:09 +0000 |
| Subject: | note 82022 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137540@lists.php.net to get a copy of this message | ||
I'm sorry to say, "andrei at novanetworks dot ro"'s method seems higly
unefficient to me. It's good if called few times only, but when most of the numbers have
already been used, the function has to loop many times before finding an available option.
When I know I need to call most of the numbers from a range, I create a list of the numbers in the
range, get a random index from this list, then return and delete the item of the list at the picked
index. More memory usage if called many times, but probably less computation time on average.
----
Server IP: 61.195.146.164
Probable Submitter: 58.159.15.76
----
Manual Page -- http://www.php.net/manual/en/function.mt-rand.php
Edit -- https://master.php.net/note/edit/82022
Del: integrated -- https://master.php.net/note/delete/82022/integrated
Del: useless -- https://master.php.net/note/delete/82022/useless
Del: bad code -- https://master.php.net/note/delete/82022/bad+code
Del: spam -- https://master.php.net/note/delete/82022/spam
Del: non-english -- https://master.php.net/note/delete/82022/non-english
Del: in docs -- https://master.php.net/note/delete/82022/in+docs
Del: other reasons-- https://master.php.net/note/delete/82022
Reject -- https://master.php.net/note/reject/82022
Search -- https://master.php.net/manage/user-notes.php