Jump to content
  • Advertisement
Sign in to follow this  
Telastyn

Which should be preferred?

This topic is 4160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Which should be preferred:
R                Function(P);
// using for_each for many

or...

{R1, R2,...}     Function({P1, P2,...});
// using a tiny set for one
Assuming a near equal mix of calls using one and using many, the function operates on one parameter only (rather than the set as a whole) and that the function body is of moderate complexity. It may or may not be parallelize-able. Which should be preferred in the general case, and why? If you think it differs depending on the specific case what sort of reasons influence it, and how?

Share this post


Link to post
Share on other sites
Advertisement
If you will often perform the operation on one element, create a one-argument version. If you will often perform the operation on several elements, create a many-argument version. You may have both in a program, if both are used frequently. You may express one in terms of the other, or make both implementations use a shared implementation building block.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!