The Source for Java Technology Collaboration
User: Password:



Start New Message Delete Post a Reply

Article: 
 Java Tech: Language Lessons
Subject:  leason on when to use Vector instead of List is missing ;-)
Date:  2005-06-02 14:35:50
From:  infernoz
Response to: leason on when to use Vector instead of List is missing ;-)


ArrayList like a like a lot Java classes (e.g. java.io.*) needlessly make useful internal varables private when they should have been protected, so making sub-classes less useful. The private array in ArrayList forced me to use Vector instead, to make an efficient ordered list e.g. Vector sort takes N*Log2(N) iterations,. Arraylist sort takes 2N*Log2(N) iterations (assuming quicksort)
e.g. Vector binary search takes at most Log2(N) iterations, Arraylist linear search takes at most N iterations. i.e. IMHO ArrayList is broken.

Yes I could use a map, but it isn't always the best solution e.g. can use more memory and be slower.

 Feed java.net RSS Feeds