maidh91 / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Document Iterables.frequency() advantages #408

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Document the advantage over Collections.frequency() for Sets and Multisets.

Original issue reported on code.google.com by ray.j.gr...@gmail.com on 27 Aug 2010 at 6:23

GoogleCodeExporter commented 9 years ago
Also, it occurs to me that a frequency() could return a negative value. Perhaps 
iteration should halt once Integer.MAX_VALUE elements are seen (ugh), in 
keeping with the definition of Collection.size().

Multiset<String> set = HashMultiset.create();
set.add("foo", (Integer.MAX_VALUE / 2) + 10);
System.err.println("Ouch: " + Iterables.frequency(Iterables.concat(set, set), 
"foo"));

Original comment by ray.j.gr...@gmail.com on 27 Aug 2010 at 6:41

GoogleCodeExporter commented 9 years ago
To the original point, I'll see what I can do, yes, thanks.

To the second... how long does that program take to run?

It's pretty well-known that a lot of things work poorly once collections get 
past 2^31 in size -- for example *Collections*.frequency().  To get the 
overflow checking means a lot of extra checks for everyone, and I'm not sure 
it's worth it.

Original comment by kevinb@google.com on 8 Sep 2010 at 6:02

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 14 Sep 2010 at 8:55

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 18 Jan 2011 at 8:35

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 26 Jan 2011 at 10:26

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 22 Mar 2011 at 7:08

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 23 Mar 2011 at 1:49

GoogleCodeExporter commented 9 years ago

Original comment by fry@google.com on 17 Jun 2011 at 5:48

GoogleCodeExporter commented 9 years ago

Original comment by kevinb@google.com on 11 May 2012 at 8:55

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:15

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:09