Collections question

J

JCary

I'm trying to figure out the best way to store and access data in this
format:


1 2 3 4 5
a a1 a2 a3 a4 a5
b b1 b2 b3 b4 b5
c c1 c2 c3 c4 c5
d d1 d2 d3 d4 d5
e e1 e2 e3 e4 e5


I have several rows and several columns of known data to be stored. For
example, I am given value a and value b and need to get the value a2. I've
done very little to no work with collections and am not sure if I should use
a multidimensional array, hashmap or what. Any help pointing me in the
right direction would be appreciated.

Cary
 
A

Andrew Hobbs

Come on now. This is homework. How about you thinking of how to do it. I
suggest reading

http://mindprod.com/jgloss/homework.html

The sentiment in the this site is worth reading and accepting. You will
learn best if you try to work it out and make a few mistakes yourself. (You
learn best from your mistakes). There is rarely a 'best way' or 'right
direction'. Which way depends upon many things. How about writing it in
several different ways, and *you* find out which is the best in your
situation. You will have learnt a whole lot more than if you are told what
to do. Remember basic computer programming is not worth much any more.
Required but not worth much. Employers want a lot more these days. On of
those is the ability to solve problems. And now is not a bad time to start
solving problems.

The important thing is to design your program so that it is simple to write
(fewer bugs) and obvious as to how it is working. If at the end of it all,
it is too slow or has other inherent problems for your purposes, then start
thinking of how you might alter it.

I also suggest reading

http://home.earthlink.net/~patricia_shanahan/beginner.html

On the other hand when you have a specific problem with your code I am sure
there will be many here who will not hesitate to give you some help.
Andrew


--
********************************************************
Andrew Hobbs PhD

MetaSense Pty Ltd - www.metasense.com.au
12 Ashover Grove
Carine W.A.
Australia 6020

61 8 9246 2026
metasens AntiSpam @iinet dot net dot au


*********************************************************
 
C

Cary Robins

Andrew,

I can appreciate how this looks like homework. However, I will expand
on what I am trying to do here. I create aircraft weight and balance
calculation systems. I convert numerical data to vector math and create
a plotter and nomograph that the flight crew utilizes to perform
aircraft weight and balance calculations. For the last year and a half
I have been creating the calculators for software use. More and more
aircraft are converting to "paperless cockpits" using tablet computers
and I'm trying to fill the need.

I'm working on a project that needs to access large tables of aircraft
data (hence the original example). I don't want to work with an
external database to maintain this data. I would like to encapsulate
all of the data in its own class. I am not asking for the answer, I
haven't worked with collections before and I am just not sure which
type of collection would be the best way to handle a lookup table.

Unfortunately, I don't have time to return to school and get a degree
in computer science. I am self taught and surrounded by piles of books.
Although I'm beyond a "hello world" program, some things are a little
harder for me to grasp from books. Andrew, you can check out what I do
at

http://www.flyincg.com

If you still don't want to help, I understand. I will figure it out
eventually. News groups are just one resource in a mountain of
information. I don't mean to be antagonizing in my post, I just want
you to know that I'm not a college student looking for answers to my
homework.

Cary
 
S

Sudsy

JCary wrote:
I have several rows and several columns of known data to be stored. For
example, I am given value a and value b and need to get the value a2. <snip>

Could you expand on that statement? I don't see how, given a and b (two
rows in your diagram), you can derive a2. Was that just a typo? What,
precisely, are you trying to lookup?
 
J

JCary

Sudsy said:
JCary wrote:
Could you expand on that statement? I don't see how, given a and b (two
rows in your diagram), you can derive a2. Was that just a typo? What,
precisely, are you trying to lookup?

Sorry, a typo on my part. I meant to type a and 2. It's just a lookup table
of values. here is a table that is more specific:

Sea Level (0 feet)
wt/deg -10 -5 0 5 10
5000 100 101 102 103 104
4000 101 102 103 104 104
3000 104 106 107 110 115
2000 and so on ...
1000

1000 feet
wt/deg -10 -5 0 5 10
5000 101 102 103 104 104
4000 104 106 107 110 115
3000 110 111 112 113 116
2000 and so on ...
1000

and so on..

I need to lookup the value for a specific altitude, weight and
temperature. I hope this helps. was thinking that a multidimensional array
would be the way to go. I am just not sure how to initialise a 4-d array
with this data.

Cary
 
A

Andrew Harker

JCary said:
Sorry, a typo on my part. I meant to type a and 2. It's just a lookup table
of values. here is a table that is more specific:

Sea Level (0 feet)
wt/deg -10 -5 0 5 10
5000 100 101 102 103 104
4000 101 102 103 104 104
3000 104 106 107 110 115
2000 and so on ...
1000

I need to lookup the value for a specific altitude, weight and
temperature. I hope this helps. was thinking that a multidimensional array
would be the way to go. I am just not sure how to initialise a 4-d array
with this data.

Cary

It looks like a 3d array to me. These sort of things can get _very
big_ so watch out. If there is a way to calculate the info you might be
better off that way .. or maybe some offsets from a base for smaller
data type

Anyway, if you use a 3d array you might also need to convert your
sea level & weight into a simple index, ie 1000->0, 2000->1 and
-10->0, -5->1 and so on.

An example array declaration is
int[][][] aircraftInfo = new int[NUM_ALTITUDES][NUM_WEIGHTS][NUM_TEMPS];
(this is basic Java syntax rather than a collection)

There are many different ways to store this sort of data and the real
answer is it all depends. Suggest you have a look for more computer
science texts on data structures, mining data etc. If it is all behind
a standard interface you can chop and change your data structure as
you see fit.
 
M

marcus

It looks like a 3D array of data, but I believe that is deceiving. It
is almost certainly the results of some ancient engineering formula
output as text for quick reference. An elegent, and very small,
solution would be to render the original formula in your software. or
buy it from someone who's already done it.

Another advantage would be the avoidance of typos -- wouldn't want
someone crashing because you were tired one night and transposed a digit
or three.

Cheers!

Andrew said:
JCary said:
Sorry, a typo on my part. I meant to type a and 2. It's just a lookup
table
of values. here is a table that is more specific:

Sea Level (0 feet)
wt/deg -10 -5 0 5 10
5000 100 101 102 103 104
4000 101 102 103 104 104
3000 104 106 107 110 115
2000 and so on ...
1000

I need to lookup the value for a specific altitude, weight and
temperature. I hope this helps. was thinking that a multidimensional
array
would be the way to go. I am just not sure how to initialise a 4-d
array
with this data.

Cary


It looks like a 3d array to me. These sort of things can get _very
big_ so watch out. If there is a way to calculate the info you might be
better off that way .. or maybe some offsets from a base for smaller
data type

Anyway, if you use a 3d array you might also need to convert your
sea level & weight into a simple index, ie 1000->0, 2000->1 and
-10->0, -5->1 and so on.

An example array declaration is
int[][][] aircraftInfo = new int[NUM_ALTITUDES][NUM_WEIGHTS][NUM_TEMPS];
(this is basic Java syntax rather than a collection)

There are many different ways to store this sort of data and the real
answer is it all depends. Suggest you have a look for more computer
science texts on data structures, mining data etc. If it is all behind
a standard interface you can chop and change your data structure as
you see fit.
 
T

Tris Orendorff

Andrew,

I can appreciate how this looks like homework. However, I will expand
on what I am trying to do here. I create aircraft weight and balance
calculation systems. I convert numerical data to vector math and
create a plotter and nomograph that the flight crew utilizes to
perform aircraft weight and balance calculations. For the last year
and a half I have been creating the calculators for software use.
More and more aircraft are converting to "paperless cockpits" using
tablet computers and I'm trying to fill the need.

I'm working on a project that needs to access large tables of
aircraft data (hence the original example). I don't want to work with
an external database to maintain this data. I would like to
encapsulate all of the data in its own class. I am not asking for the
answer, I haven't worked with collections before and I am just not
sure which type of collection would be the best way to handle a lookup
table.

Unfortunately, I don't have time to return to school and get a degree
in computer science. I am self taught and surrounded by piles o


Hi,

Do me a favor and hire a consultant who knows what he or she is doing. The last thing I want is to have
my plane crash because the flight crew overloaded the 747 with freight and it ran out of fuel half way to its
destination.

--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d++ s+:- a+ C+ UL++++ P+ L+ E- W+ N++ o- K++ w+ O+ M !V PS+ PE Y+ PGP t+ !5 X- R- tv--- b++
DI++ D+ G++ e++ h---- r+++ y+++
------END GEEK CODE BLOCK------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,211
Latest member
NelleWilde

Latest Threads

Top