|
-
Feb 18th, 2002, 12:16 PM
#1
Thread Starter
Addicted Member
Vectors
Is there a Vector package in Java like there is in C++? I'm aware that C++ uses vectors as arrays and I remember someone on these forums saying to me that the Vector class in Java implements something similar to the Dynamic Array function in VB. This true?
"'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."
-
Feb 18th, 2002, 12:54 PM
#2
Dazed Member
The java.util.Vector class is declared
synchronized which means that the
integrity of the data it holds will not be
jeopardized by concurrent access.
java.util.ArrayList offers slightly better
performance as it has no synchronization.
-
Feb 19th, 2002, 02:45 PM
#3
Dazed Member
Just to add....... You could add synchronization to a class that
is not synchronized by using some static factory methods defined within the Collections class (not to be confused with the Collections interface). You could essentially use an ArrayList and get the same thread saftey that the Vector and Hashtable classes provide using this approach.
Code:
List synclist = Collections.synchronizedList(somelist);
synchronized(synclist){
for(Iterator i = synclist.iterator();i.hasNext();)
doSomthing(i.next())
}
-
Feb 20th, 2002, 04:48 AM
#4
Addicted Member
Yes its true! its in java.util.Vector.
Ford? Theres an infinite number of monkeys outside that want to talk to you about a script of hamlet they've produced!
-
Feb 20th, 2002, 05:28 AM
#5
Thread Starter
Addicted Member
And here's me after writing a Dynamic Array class. Sigh
"'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."
-
Feb 20th, 2002, 04:31 PM
#6
Hyperactive Member
lol, that is they way it usually happens. It is good for you, that way you probably learned in the process. I try to do that from time to time, rewrite things that already exist just so my level of skill stays high enough.
-
Feb 21st, 2002, 01:11 AM
#7
Dazed Member
Posted by billrogers
lol, that is they way it usually happens. It is good for you, that way you probably learned in the process. I try to do that from time to time, rewrite things that already exist just so my level of skill stays high enough.
I do the same thing also when i get bored or im in the middle of trying to figure out my next project. Youre right it does keep you sharp.
-
Feb 21st, 2002, 05:58 AM
#8
Thread Starter
Addicted Member
Yeah, I'm actually glad I wrote the artificial Dynamic Array class - even if it is a little cumbersome sometimes.
"'Oh, hello Mr. Crick! What do you think of Jeffrey Archer?' Clip-clip-clip! Oh, come on! Who are you kidding? You wait til I'm mayor, you'll see how tough I am! Christ almighty...."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|