check this in anyway, at least for posterity.
The advantages over the 'CountingMap' (currently in yohoho):
- Faster, because adding to a count doesn't add to a boxed int, nor does
it hash twice (except on the intial use of a particular key).
The disadvantages:
- More complicated implementation (CountingMap builds upon google
collections)
- If a non-HashMap is desired, the fact that the underlying map is
<K, int[]> is exposed.
- When iterating over the entrySet, each entry is a new object
created solely for your iteration.
So.. yeah. I'll check it in. Maybe I'll blow it away. We should
probably think about how samskivert will move forward- do we want to
depend on google-collect or guava? Do we want to deprecate huge
swaths of this library in preference to those? A lot of what's
in here is a bit outdated, but maintained to support code built
atop it.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2704 6335cc39-0255-0410-8fd6-9bcaacd3b74c
- Provide an implementation in AbstractIntSet that checks the interator
for at least one element.
- Override that in ArrayIntSet so that we're just checking our size again.
- Added optimized isEmpty()s for a few of the inner classes in IntSets.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2701 6335cc39-0255-0410-8fd6-9bcaacd3b74c
Oh baby, look at the @SuppressWarnings and cast removal.
It's all itchy, flakey, and pale under the cast!
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2695 6335cc39-0255-0410-8fd6-9bcaacd3b74c
(RangeIntSet, CompleteIntSet & ClumpyArrayIntSet (which both are capable
of holding every int, and not maxing out at Integer.MAX_VALUE size)).
But here's a bunch of useful stuff all wrapped up nicely.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2690 6335cc39-0255-0410-8fd6-9bcaacd3b74c
- Don't wig-out trying to grow from a size larger
than half of Integer.MAX_VALUE.
- Don't try to add any values once size reaches Integer.MAX_VALUE.
- Fixed the Interator's remove() to behave properly should it be
called improperly.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2679 6335cc39-0255-0410-8fd6-9bcaacd3b74c
The RunBuddy posted to a RunQueue will call its Interval's
toString() method. If an Interval is created with a Runnable,
let's call the Runnable's toString().
We could also add a form of create() that takes a String for the name...
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2676 6335cc39-0255-0410-8fd6-9bcaacd3b74c
the Executor interface.
- Also accept our "receiver" as an Executor, deprecating the old RunQueue
constructor.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2671 6335cc39-0255-0410-8fd6-9bcaacd3b74c
Provide a method for getting a Comparable Comparator in a typesafe way.
I had to change the Comparator to be untyped.
Hopefully this doesn't hork anything. Oh, now I worry...
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2664 6335cc39-0255-0410-8fd6-9bcaacd3b74c
Is this weird? Maybe. It violates the requirment that the Comparable relation
is transitive, because the "other" object need not even be Comparable.
java.util.Arrays.binarySearch() (added in 1.6) is documented as if it
supports this behavior, but it does not.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2661 6335cc39-0255-0410-8fd6-9bcaacd3b74c
Wrap it in an AssertionError.
I looked to Java sources to see what the best practice was:
Sometimes it's ignored, sometimes an InternalError is thrown,
sometimes an AssertionError without the "cause", but sometimes
this pattern, which is clearly the best of those.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2660 6335cc39-0255-0410-8fd6-9bcaacd3b74c
does not permit null (or, obviously, elements of the wrong type),
but is gracious about simply returning false if an invalid
Object is passed to contains() or remove().
- Implement a dumb size().
- toIntArray() impl now deals with oversize IntSets.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2657 6335cc39-0255-0410-8fd6-9bcaacd3b74c
but that's like half the point of the containsKey() method!
- check for shrinkage when values are removed from the keySet, but avoid
doing iteration-breaking shrinking modifications when remove() is called
on any of our iterators.
- Slight performance improvement on keySet.remove().
- Other simplifications.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2655 6335cc39-0255-0410-8fd6-9bcaacd3b74c