Commit Graph

2635 Commits

Author SHA1 Message Date
ray.j.greenwell 5bf7699dd4 Missed a spot.
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
2010-01-13 17:49:25 +00:00
ray.j.greenwell de860c5602 Now that this library is JDK 1.5, let's return the true type from clone().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2694 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-13 17:44:50 +00:00
samskivert 7480bb2e6c We should be toString-ing right into our StringBuilder and using the specified
open and close boxes for the internal elements of our sequences.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2693 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-11 05:19:38 +00:00
ray.j.greenwell 818e108f99 Nix import.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2692 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-08 22:05:22 +00:00
ray.j.greenwell d2464d9feb JDK 1.5 compatibility.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2691 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-08 22:04:02 +00:00
ray.j.greenwell 503d57d7de I've been messing with IntSets. I won't check in my more esoteric classes
(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
2010-01-08 18:52:36 +00:00
ray.j.greenwell 61609ffcd5 Be more efficient if constructed with an Interable.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2689 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-08 18:47:28 +00:00
ray.j.greenwell 32d01f5651 Broke-out the notification that we've been posted to a shutdown RunQueue
into a method, so that it can be suppressed, etc.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2688 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-06 20:16:52 +00:00
ray.j.greenwell 838d725bb6 Sorry, Pär, you get slurped up into "et al." like me.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2687 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-06 01:01:03 +00:00
ray.j.greenwell ff9798927c Updated copyright dates, and holder. :)
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2686 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-06 00:53:25 +00:00
ray.j.greenwell f57af39108 Drop unneeded import.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2685 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-06 00:31:57 +00:00
ray.j.greenwell 42c7ea0009 This should be more efficient, right?
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2684 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-06 00:31:36 +00:00
ray.j.greenwell ee8f1aab7e Hey, samskivert requires 1.5 now, so let's label our Timer thread.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2683 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-06 00:28:11 +00:00
ray.j.greenwell 99a46d1613 Spell the package name correctly.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2682 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-05 19:02:21 +00:00
ray.j.greenwell 5282228ee9 Move Mapping all the way up to samskivert.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2681 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2010-01-05 00:56:19 +00:00
ray.j.greenwell 1a56333166 Nixed unneeded @SuppressWarnings, from Jamie Doornbos.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2680 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-14 19:27:20 +00:00
ray.j.greenwell deb50bc136 - Behave better at large sizes.
- 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
2009-12-11 23:39:53 +00:00
ray.j.greenwell 791121ff37 I picked the wrong week to stop sniffing glue.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2678 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-10 22:33:45 +00:00
ray.j.greenwell 84c6cce89a Make get(), containsKey(), and remove() tolerant of non-Integer objects.
Our IntSets now do this, including the keySet returned by this class.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2677 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-10 20:18:17 +00:00
ray.j.greenwell 2d20fd3454 For debugging, an Interval's toString() should be informative.
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
2009-12-10 19:58:35 +00:00
ray.j.greenwell 6819b85c66 I was a bit overzealous in my import removal.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2675 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-08 20:03:18 +00:00
ray.j.greenwell a6d64b1605 Fuckit. Executor all the way.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2674 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-08 19:57:52 +00:00
ray.j.greenwell 2c04b41b66 More Executor preferring.
Maybe I'm just crazy.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2673 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-08 19:04:49 +00:00
ray.j.greenwell 44c1d15c4b Added an Executor adapter class to RunQueue...
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2672 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-08 19:02:32 +00:00
ray.j.greenwell 7fb3c3354c Well, it's called "SerialExecutor", it would be a shame not to implement
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
2009-12-07 21:23:18 +00:00
ray.j.greenwell 50862df9c3 Implement java.util.concurrent.Executor.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2670 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-07 21:18:52 +00:00
ray.j.greenwell 197c6fbbf8 Modernization from Dave Hoover.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2669 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-05 01:52:48 +00:00
ray.j.greenwell 6ca4287fb8 Some happiness for Eclipse, apparently, from Dave Hoover.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2668 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-05 01:52:26 +00:00
ray.j.greenwell a600bcae9c Slap on the old @Override; caught by David "David Hoover" Hoover.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2667 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-05 01:23:52 +00:00
ray.j.greenwell 09dbc956e5 Damn.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2666 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-05 00:00:32 +00:00
ray.j.greenwell 9a2a755931 Look ma, less code.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2665 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-05 00:00:18 +00:00
ray.j.greenwell bfe3ef5096 I may fiddle around with this, but here's one that works.
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
2009-12-04 23:59:42 +00:00
ray.j.greenwell 0a5255f421 Superclass now has a method with a nearly identical signature
and we've been caught forging its checks!


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2663 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-04 22:54:22 +00:00
ray.j.greenwell 983279beae Added a binarySearch() that allows a key to be provided that isn't
the same type as our elements, as long as it can compare our element types.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2662 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-04 20:36:13 +00:00
ray.j.greenwell c64d46d0d8 Allow non-Comparable arrays to be searched using a Comparable key.
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
2009-12-04 20:35:10 +00:00
ray.j.greenwell 394d37fbc6 Clean up CloneNotSupportedException handling in Cloneables.
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
2009-12-02 22:48:26 +00:00
ray.j.greenwell e612575c58 Deprecated, a replacement class now exists in the JDK.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2659 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-02 22:44:45 +00:00
ray.j.greenwell 61b3fca73a Rejiggering.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2658 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-02 21:30:17 +00:00
ray.j.greenwell 3658a26e13 - Change of heart: Let's follow the example of EnumSet, which
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
2009-12-02 21:29:40 +00:00
ray.j.greenwell 57dffcb1a5 Bugfix: Our entries should compare as equal to any Map.Entry<Integer, K>
with the same key and value.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2656 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-12-01 21:34:58 +00:00
ray.j.greenwell 00ede903a2 - Bugfix: containsKey() returned false if the associated value was null,
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
2009-12-01 21:00:32 +00:00
ray.j.greenwell aa0666e475 clone() was broken. If you had a StreamableHashIntMap and cloned it
you would get a HashIntMap.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2654 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-25 22:13:16 +00:00
ray.j.greenwell 98f75b8d8d Per Dave Hoover:
- 1.5 compatibility: Removed @Override on some methods that
  had no concrete implementation in superclasses.
- Added @Override to a few places where there does happen to
  be an implementation in our abstract superclass.
I now think the 1.6 behavior of @Override is more sensible, it's
less special-casey.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2653 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-25 20:17:03 +00:00
ray.j.greenwell b470236333 Just remove these and let AbstractCollection's implementations stand.
WARNING: behavior change! May cause runtime errors!

- Previously these methods would always return an Integer[], which is
  incorrect. The toArray() version should always return an Object[],
  and the toArray(T[] a) version should return an array of the same
  type as that passed in, even if a supertype of T (like Object[]).
- The toArray(T[] a) version was not doing any size checking, nor
  doing any of the required steps if the size doesn't match.

This change may break something, but it brings this class into
compliance with the Collection interface.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2652 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-24 21:09:01 +00:00
ray.j.greenwell bdda88cd45 Actually, let's go ahead and NPE or CCE in remove() and contains() if
the specified object is not an Integer. We're allowed to do that
per the Collection interface spec, and ArrayIntSet previously had
that behavior (but the IntMap keySets did not...).


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2651 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-24 20:34:44 +00:00
ray.j.greenwell e8e6c95565 Undo this, the NPE will happen automatically..
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2650 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-24 20:29:19 +00:00
ray.j.greenwell 5443630f99 IntSet/Interator cleanup.
- Fully filled-out AbstractIntSet with default implementations of most
  things and documented the two methods that must be provided (interator()
  and size()) as well as the ones that should probably be overridden for
  performance or to make one mutable.
- Fixed implementations of contains(Object o) and remove(Object o) to not NPE.
- Return hashCode() identically to the way Set<Integer> would.
- Created an AbstractInterator.
- Added notes where I believe an implementation is bogus...


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2649 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-24 20:28:00 +00:00
ray.j.greenwell dd4f8da52a One last try, to support usages in yohoho, as advised by Michael Thomas.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2648 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-19 23:47:48 +00:00
ray.j.greenwell a0425478d6 Ok, let's specify it the other way around, per feedback from Michael Thomas.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2647 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-19 23:39:49 +00:00
ray.j.greenwell bb34cba00f Wow, the signatures on these were way wrong. Let's fix them and break
binary compatibilty! Whee!
I genericized these when I was first using generics, before I understood the
"PECS" rule.

It seems to me that these could be
  <T> Collection<T> addAll (Collection<T> col, Iterator<? extends T> iter);
(rather than)
  <T> Collection<? super T> addAll (Collection<? super T> col, Iterator<T> iter);
..but in fact there is already a java.util.Collections.addAll() that takes
an array and specifies the type as that of the producer.
So I followed that. I'm not sure which would be more correct.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@2646 6335cc39-0255-0410-8fd6-9bcaacd3b74c
2009-11-19 22:17:12 +00:00