Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Apr 30th, 2008, 5:27 PM   #11
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
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.
mbd is offline   Reply With Quote
Old Apr 30th, 2008, 6:11 PM   #12
lectricpharaoh
Caffeinated Neural Net
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 895
Rep Power: 4 lectricpharaoh will become famous soon enough
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.
__________________
A man's knowledge is like an expanding sphere, the surface corresponding to the boundary between the known and the unknown. As the sphere grows, so does its surface; the more a man learns, the more he realizes how much he does not know. Hence, the most ignorant man thinks he knows it all. - L. Sprague de Camp
lectricpharaoh is offline   Reply With Quote
Old May 1st, 2008, 12:33 AM   #13
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
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.
mbd is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:53 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC