![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Programmer
Join Date: Nov 2007
Posts: 86
Rep Power: 1
![]() |
Re: populate array with random nonrepeating #'s
that is a lot of work to do two things. 1) create an enumerable of a series of integers 2) shuffle any enumerable of any type
your code only works for a very specialized case. |
|
|
|
|
|
#12 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,051
Rep Power: 5
![]() |
Re: populate array with random nonrepeating #'s
This topic was discussed not too long ago in this thread. In post #8, I offered a solution using generics that will shuffle an array. Thus, you can easily create a 42-element array, initialize each element (inside a
for() loop), and then hand the array off to be shuffled. This guarantees each value will appear once, and only once, within the array.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Nov 2007
Posts: 86
Rep Power: 1
![]() |
Re: populate array with random nonrepeating #'s
your use of generics allows you to shuffle any type of array. my class allows for any type and any container to be shuffled. my series class is really not part of the exercise.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning Values into Random Index's in Array | csrocker101 | C# | 9 | Mar 20th, 2008 3:46 AM |
| Random image array | Smessed-Up | JavaScript and Client-Side Browser Scripting | 3 | Mar 7th, 2008 7:40 PM |
| ADA Random Seed of an Array | scm007 | Other Programming Languages | 1 | Mar 25th, 2007 9:05 PM |
| random numbers in 2D array | cwl157 | Java | 4 | Apr 29th, 2005 6:08 AM |
| Installing IPB 2.03 | bh4575 | Other Web Development Languages | 0 | Apr 23rd, 2005 2:36 AM |