On Monday, 31 March 2014 14:32:16 UTC-4, Christian Gruber wrote:
>
> On 31 Mar 2014, at 11:20, Tavian Barnes wrote: 
>
> > On Monday, 31 March 2014 13:03:57 UTC-4, Christian Gruber wrote: 
> >> 
> >> This actually looks a lot like a ListMultimapBinder to me. :) 
> >> 
> > 
> > I don't see why, what type would the key have and where would they 
> > come 
> > from? 
>
> Whatever comparable you wanted to use for ordering. 
>
> > A ListMultimapBinder would have the same issues potentially: 
>
> Crap - I was thinking more of a TreeMultimap, but said ListMultimap - 
> the word List got stuck in my head. I was thinking order guarantees 
> about the keys, not the values for a given key. :/ 
>
> The reason I'm thinking Multimap not List, is that List does suffer from 
> an inter-module ordering problem - you'll get groupings within the list, 
> but within those groupings, you'll have non-guaranteed order, which 
> violates the general expectations for List behaviour.  OTOH, a Multimap 
> has keys which have an order, and you can express it as a map of 
> collections of values (or iterate over the keySet()) which has (if the 
> type is comparable) an ordering you can make implicit or explicit, and 
> they are unique, so they group values.  And if you make it a 
> TreeMultimap with natural ordering, you can simply use your ordinal 
> integers as the keys and you get the behavior you're describing - 
> priority grouping. 
>

I see what you're saying.  I'm not even sure you need a Multimap, I think a 
TreeMapBinder/SortedMapBinder would do fine.

In fact, one way to implement ListBinder would be to use a MapBinder 
internally with priority->object bindings, copy it to a TreeMap, then copy 
the values to a list. 
 

> That seems like a clearer API expressing what you're actually doing when 
> you're building the list.  With the ListBinder approach you propose, 
> you're saying, there's an order to these entries... except when there 
> isn't.  Or am I missing something?


I was thinking the priorities would constitute an absolute ordering for the 
entries (i.e., duplicate priorities prohibited).  Then they have a unique 
ordering even split across modules. 

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/d/optout.

Reply via email to