which one do you prefer?
I want to make a finite automata in java; is it more efficient using vector or set?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A Vector is a class. A Set is an interface. I would use an ArrayList instead of a Vector anyway, if you’re not doing something that needs to be threadsafe. Or a standard array if it’s not going to get resized.
It really depends on your application though. Specifically, Sets don’t allow duplicate elements, whereas Arrays (Arraylists, Vectors) do.
Personally I would use an array, unless it needed to have some kind of special functionality (resizing, no duplicate elements, etc.)