|
-
Nov 6th, 2003, 11:52 AM
#1
Thread Starter
Member
Complex Multidimensional Array Ops...
I have a C# class that reads in a four-dimensional array from a series of flat text files. The clients of this class won't need access to all of the data at any one time, only certain parts of it. Is there a way I can write a method to return a multidimensional array with specific dimensions eliminated?
For instance, take an array of sales figures:
Code:
double[,,,] dSales = new double[NUM_YEARS, NUM_MONTHS, NUM_SALESPEOPLE, NUM_PRODUCTS];
This array provides sales figures organized by year, month, salesperson, and product. If a client needs access to sales figures of product #2 in August, it only needs a two dimensional array (year and salesperson). The other two dimensions (month and product) have been specified.
Is this even possible? If so, any ideas on how to implement it?
-
Nov 6th, 2003, 05:06 PM
#2
PowerPoster
Check out the Array.Copy() method.
-
Nov 7th, 2003, 05:37 AM
#3
Hyperactive Member
Maybe you want to take closer look at the vector possibilitys of c#!
Dont know much about it, but it sounds like a typical vector or ArrayList problem.
Hope that helps,
Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Nov 7th, 2003, 11:24 AM
#4
Thread Starter
Member
I checked MSDN regarding the Array.Copy method. It's meant to work on one-dimensional arrays. Multidimensional arrays are treated as flat arrays. I need something that recognizes that the arrays I'm copying from and to are multidimensional.
I couldn't find anything on vectors, aside from how they apply to matrices and cryptography. Got anything more specific, Sgt-Peppa?
-
Nov 7th, 2003, 11:37 AM
#5
Hyperactive Member
Heres a link to an array list msdn example.
Maybe thats what your looking for!
http://msdn.microsoft.com/library/de...classtopic.asp
Hope that helps.
Stephan
Keep Smiling - even if its hard 
Frankie Says Relax, wossname Says Yeah!
wossname:--Currently I'm wearing a gimp suit and a parachute.
C# - Base64 Blog
-
Nov 7th, 2003, 05:03 PM
#6
Thread Starter
Member
I don't really think that ArrayLists will help me. The problem is not dynamically adding items, but rather trying to access subsets of elements. I guess I can just write a new method everytime I need to access a different type of array...but I was really hoping for some way to do this more dynamically.
-
Nov 8th, 2003, 04:30 PM
#7
yay gay
the best way in my opinon is to create a method that takes as arguments the dimensions / length that you want to retrieve although it will require some maths at how to do it
\m/  \m/
-
Nov 8th, 2003, 04:48 PM
#8
Frenzied Member
Re: Complex Multidimensional Array Ops...
Originally posted by smiley_dood
I have a C# class that reads in a four-dimensional array from a series of flat text files. The clients of this class won't need access to all of the data at any one time, only certain parts of it. Is there a way I can write a method to return a multidimensional array with specific dimensions eliminated?
For instance, take an array of sales figures:
Code:
double[,,,] dSales = new double[NUM_YEARS, NUM_MONTHS, NUM_SALESPEOPLE, NUM_PRODUCTS];
This array provides sales figures organized by year, month, salesperson, and product. If a client needs access to sales figures of product #2 in August, it only needs a two dimensional array (year and salesperson). The other two dimensions (month and product) have been specified.
Is this even possible? If so, any ideas on how to implement it?
Why dont you just write a struct or a class to hold the sales information, then read in the info, then add the object to an arraylist. You can always retrieve the info you want from each object when you need to.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|