dcsimg
How to get from Iterator to Vector.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   David_Pantich
Posted On:   Friday, December 6, 2002 08:00 AM

Hello,


Is it possible to take an iterator (returned by a method) and somehow get it into a Vector or List or some other kind of Collections object without having to build the Vector from scratch by looping through the whole iterator and adding each element to the Vector?


For example, Vector has the addAll() method but it won't take an iterator as input.


Any help would be GREATLY appreciated.

Re: How to get from Iterator to Vector.

Posted By:   Kiril_Dunn  
Posted On:   Monday, January 13, 2003 04:39 PM

The addAll() method simply obtains an iterator from the collection and loops through it anyway, so you won't have any performance degradation by doing that.


If you were wanting to save some typing, you could make your own subclass of Vector and add another addAll() method that takes an Iterator as a parameter.


Hope this helps,


Kiril

About | Sitemap | Contact