palolove / google-collections

Automatically exported from code.google.com/p/google-collections
0 stars 0 forks source link

Position based access of LinkedListMultimap #288

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

I am using your collection LinkedListMultimap for storing duplicate
key-value pairs and maintain the insertion order, it performs well for key
based access compared to a pure LinkedList based implementation i have
written, but position based operations are not allowed directly, i am doing
everything with entries() view (it is causing performance overhead compared
to pure linkedlist), is it possible i can do positional access similar to a
LinkedList in this collection using a workaround? or get a ListIterator
which can traverse backward from the end in entries() view? Please let me
know. Thanks in advance.

Regards,
Ram 

Original issue reported on code.google.com by ram.6...@gmail.com on 3 Nov 2009 at 6:52

GoogleCodeExporter commented 8 years ago
I think you're saying that you'd like values() and/or entries() to return 
Lists, yes?

Original comment by kevin...@gmail.com on 5 Nov 2009 at 1:09

GoogleCodeExporter commented 8 years ago
I believe we also had idle thoughts of making ImmutableMap.values() return
ImmutableList.  The same would be true of ImmutableMap.entrySet(), except that 
it's a
Set, so it can't be a List.  Resolving issue 229 (ImmutableCollection.asList() /
ImmutableList.copyOf(nonListImmutableCollection) doesn't make a copy) would be a
solution for the ImmutableMap/ImmutableMultimap/etc. case.

Original comment by cpov...@google.com on 5 Nov 2009 at 1:39

GoogleCodeExporter commented 8 years ago
If performance isn't a concern, you can retrieve elements by position with the 
command
  Iterables.get(multimap.entries(), position);

For better performance, you could say
  List<Map.Entry<K, V>> entryList = Lists.newArrayList(multimap.entries());
Then you could easily access arbitrary entries and call Entry.setValue(). 
However,
adding or removing records from the multimap wouldn't change the list, and vice 
versa.

Having LinkedListMultimap.entries() return a List makes sense conceptually, but 
there
may not be enough demand to justify that change.

Chris, ImmutableMap can't have a values() returning an ImmutableList because its
subclass ImmutableBiMap has a values() method returning an ImmutableSet.

Original comment by jared.l....@gmail.com on 5 Nov 2009 at 2:10

GoogleCodeExporter commented 8 years ago
This issue has been moved to the Guava project (keeping the same id number). 
Simply replace 'google-collections' with 'guava-libraries' in your address 
bar and it should take you there.

Original comment by kevinb@google.com on 5 Jan 2010 at 11:09