java - What is the time complexity of Collection.toArray()? -


what time complexity of method collection.toarray()? o(n), if yes benefits offer on looping , individually assigning values in list array( beside nice , effort of course).

because toarray() method abstract, speaking time complexity in general makes no sense.

however, native implementations, complexity indeed o(n). noteworthy collection subinterface of iterable. quite absurd implement iterable cannot efficiently iterated over.

the fact implementation of toarray() kept open, leaving space optimizations. there may approaches faster building array using simple iteration (array copying, running in multiple threads...). however, default implementaion in abstractcollection uses exact approach mention in question.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -