Results 1 to 8 of 8

Thread: Vectors

  1. #1

    Thread Starter
    Addicted Member MethadoneBoy's Avatar
    Join Date
    Oct 2001
    Location
    Preferably somewhere between Keira Knightley and Diane Kruger but I'm not fussy
    Posts
    180

    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...."

  2. #2
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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.

  3. #3
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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())
     }

  4. #4
    Addicted Member Mrs Kensington's Avatar
    Join Date
    Sep 2001
    Location
    Dorset, UK
    Posts
    144
    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!

  5. #5

    Thread Starter
    Addicted Member MethadoneBoy's Avatar
    Join Date
    Oct 2001
    Location
    Preferably somewhere between Keira Knightley and Diane Kruger but I'm not fussy
    Posts
    180
    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...."

  6. #6
    Hyperactive Member
    Join Date
    May 2000
    Posts
    367
    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.

  7. #7
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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.

  8. #8

    Thread Starter
    Addicted Member MethadoneBoy's Avatar
    Join Date
    Oct 2001
    Location
    Preferably somewhere between Keira Knightley and Diane Kruger but I'm not fussy
    Posts
    180
    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
  •  



Click Here to Expand Forum to Full Width