|
From: SourceForge.net <no...@so...> - 2012-08-13 18:33:16
|
Bugs item #3556860, was opened at 2012-08-12 22:30 Message generated for change (Comment added) made by robeden You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=424682&aid=3556860&group_id=39235 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: API Group: Next Minor Release >Status: Closed >Resolution: Wont Fix Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) Assigned to: Nobody/Anonymous (nobody) Summary: values() is not Collection<T> Initial Comment: Typical usage of values() in the Java API for Map<K, V> is values() returns Collection<V>. In trove, values() returns Object[] which is really obnoxious to iterate. I don't mind if you provide this but if you could also provide the collection that would make a lot more sense. ---------------------------------------------------------------------- >Comment By: Rob Eden (robeden) Date: 2012-08-13 11:33 Message: Trove imitates the Collections API, but is not intended to be an exact copy (it can't be in many cases). From your description, I assume you're using something like a TIntObjectMap<T>. In this case, you will see two variations: - values() : returns Object[] - values( T[] ) : returns T[] I assume the difficulty iterating comes from needing to case the objects. In which case, you should use the second variation (just like toArray(...) in the Java Collections). Trove's primary purpose is speed and efficiency. Arrays are used in this case because it's the most efficient form and possible to use without memory allocation. Arrays are used throughout Trove, so this is pretty familiar if you use the library heavily. If you're looking more for compatibility with the Collection API and ease of use, take a look at the TDecorators class. That will let you wrap a Trove collection in a Collections interface so it works as you're used to (at a performance cost). ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=424682&aid=3556860&group_id=39235 |