Solved

calculate a reference key with parameters of 0-99 (100 entries max)

Posted on 2004-08-14
3
192 Views
Last Modified: 2010-04-01
Hi,

I am needing some advice on how to calculate a reference key.  The function I have is
int getReferenceKey(int key)
the value of the key is calculated by the formula
key=(location index)*10+(type index.)

thanks.

Kaz
0
Comment
Question by:KazIT
  • 2
3 Comments
 
LVL 19

Expert Comment

by:mrwad99
ID: 11799399
Kaz

Can you clarify exactly what you are after please as it is not quite clear.

Cheers
0
 

Author Comment

by:KazIT
ID: 11803051
The program I am constructing will have up to 100 entries, consisting of say 6 columns of information.  Each line of each entry needs to have a reference key assigned to it.
0
 
LVL 19

Accepted Solution

by:
mrwad99 earned 500 total points
ID: 11803566
So just make some formula up and get a value from that.  You are already doing something like this according to your first post; simply chose another formula that generates a unique value.

If you have 100 entries, numbered 1-100 or 0 - 99, and six columns, numbered 1 - 6 or 0 -5, then a reference key could be entry * column with a little more 'spice' added to it.  Alternatively you could always use the address of each entry, that is guaranteed to be unique.

HTH
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question