473,388 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Which is faster code: Enumeration or Constants?

I have to do a lot of calculations when leaving certain controls.
Somewhere along the order of 800 to 1000 fields.

I'm considering translating all of the numeric fields that are in a
string collection into a fixed double array. I would use the already
converted doubles in the calculations. I could access the double array
by either constants or by an enumeration. Does anybody know which way
is faster, if any?

The most elegant solution would be to create a new collection of
doubles and use the named entries in my original string collection. I
worry about the slowness of accessing the data using the hash
algorithm in a collection vs. accessing a simple double array.

Shane
Nov 21 '05 #1
1 1062
In general, there's not a whole lot of difference. Read these two blog
posts:

http://blogs.gotdotnet.com/BradA/per...8-e3188129abe9
http://blogs.gotdotnet.com/BradA/per...0-0707d6747225

From those 2 posts, it seems that you should be using Enums.

hope that helps..
Imran.

"Shane" <sh***********@yahoo.com> wrote in message
news:4b**************************@posting.google.c om...
I have to do a lot of calculations when leaving certain controls.
Somewhere along the order of 800 to 1000 fields.

I'm considering translating all of the numeric fields that are in a
string collection into a fixed double array. I would use the already
converted doubles in the calculations. I could access the double array
by either constants or by an enumeration. Does anybody know which way
is faster, if any?

The most elegant solution would be to create a new collection of
doubles and use the named entries in my original string collection. I
worry about the slowness of accessing the data using the hash
algorithm in a collection vs. accessing a simple double array.

Shane

Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexander Eisenhuth | last post by:
Hello alltogether, I hope somebody can help me in that case. I bet I have overseen s.th.. I have a VC++ IDispatch Com-Server (ATL) and include for error handling issues a enumeration in the...
10
by: cppaddict | last post by:
I would like to write, within the private section of my class definition: static enum TruncType {TRUNC_TOP,TRUNC_RIGHT,TRUNC_BOTTOM,TRUNC_LEFT}; but C++ does not allow this. The four values...
36
by: Vivek Mandava | last post by:
Hello All, Which one is an expensive operation? '>' or '==" ? I know this won't matter much. However, if I'm executing this operation million times, I would prefer the better choice. My...
12
by: junky_fellow | last post by:
Which is better using a switch statement or the if-then equivalent of switch ?
27
by: Ben Finney | last post by:
Antoon Pardon wrote: > I just downloaded your enum module for python > and played a bit with it. IMO some of the behaviour makes it less > usefull. Feedback is appreciated. I'm hoping to...
3
by: aarklon | last post by:
Hi all, in the article http://www.c-faq.com/struct/enumvsdefine.html it is written as Some advantages of enumerations are that the numeric values are automatically assigned, that a debugger...
4
by: Jason | last post by:
Can someone explain, or point me to a good link that explains enumerations for a newbie. Thats
2
by: Charlie | last post by:
Hi: How would I bind a list to an enumeration so that enumeration value becomes list values and enumeration constants becomes list text? Do you loop through enum and add manually or is there a...
61
by: arnuld | last post by:
I have created a program which creates and renames files. I have described everything in comments. All I have is the cod-duplication. function like fopen, sprint and fwrite are being called again...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.