Jump to content

  • Log In with Google      Sign In   
  • Create Account

Debating on which collection class to use for project


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 warnexus   Prime Members   -  Reputation: 1433

Like
0Likes
Like

Posted 07 April 2013 - 11:22 AM

I have a project in Java that requires these features to be operated on one-variable polynomials

 

1) Input a polynomial

2) Print a polynomial

3) Add two polynomials

4) Subtract two polynomials

5) Multiply two polynomials

6) Find a derivative of a polynomial

7) Evaluate a polynomial at a specific value

 

My professor suggested using the Vector Class but I did research and Vector are usually used in a multi-threaded environment and there is an synchronized overhead on individual operation but given the features involved in this project does not require multi-threading or any type of threading.

 

I saw no problems reading about ArrayList. ArrayList are good to use in single-threaded environment and also given my experience using it. Based on my research, ArrayList has all the benefits in the world for these features.

 

I'm in a conundrum right now. I need advice.  


Edited by warnexus, 07 April 2013 - 11:24 AM.


Sponsor:

#2 Yrjö P.   Crossbones+   -  Reputation: 1412

Like
0Likes
Like

Posted 07 April 2013 - 04:24 PM

What advice? You already know the better choice, and why it's the better choice.

 

(Not that it really matters which you use, obviously the exercise is not about performance and either would work equally well.)



#3 ultramailman   Prime Members   -  Reputation: 1571

Like
0Likes
Like

Posted 07 April 2013 - 06:04 PM

Does performance matter in this project? Will using one over the other give significant human observable performance penalties? If not, then it probably does not matter.

#4 ysg   Members   -  Reputation: 192

Like
0Likes
Like

Posted 07 April 2013 - 06:17 PM

I have a project in Java that requires these features to be operated on one-variable polynomials
 
1) Input a polynomial
2) Print a polynomial
3) Add two polynomials
4) Subtract two polynomials
5) Multiply two polynomials
6) Find a derivative of a polynomial
7) Evaluate a polynomial at a specific value
 
My professor suggested using the Vector Class but I did research and Vector are usually used in a multi-threaded environment and there is an synchronized overhead on individual operation but given the features involved in this project does not require multi-threading or any type of threading.
 
I saw no problems reading about ArrayList. ArrayList are good to use in single-threaded environment and also given my experience using it. Based on my research, ArrayList has all the benefits in the world for these features.
 
I'm in a conundrum right now. I need advice.

Make small subsets of your project using both approaches and see which ones suit you best. As for the performance hit, unless your project has timing restrictions (which I doubt), it doesn't really matter.

#5 warnexus   Prime Members   -  Reputation: 1433

Like
0Likes
Like

Posted 07 April 2013 - 06:29 PM

Thanks



#6 LorenzoGatti   Crossbones+   -  Reputation: 2694

Like
0Likes
Like

Posted 08 April 2013 - 02:33 AM

You don't have to worry about multiple threads: first because it doesn't seem to be a requirement of your exercise, second because if the need arises you can define a Polynomial class and put synchronized {} blocks where you really need them. Hint: your polynomials are almost read-only.
Produci, consuma, crepa




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS