equals(), hashCode() updated/added, also a few minor changes
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@110 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
4badd54216
commit
f810412d75
|
|
@ -20,6 +20,7 @@ public class CountedObject<T> {
|
|||
* @param o object to start counting for
|
||||
*/
|
||||
public CountedObject(T o) {
|
||||
assert o!=null : "Can not create counted object over null";
|
||||
mObject = o;
|
||||
mCounter = 1;
|
||||
}
|
||||
|
|
@ -30,6 +31,7 @@ public class CountedObject<T> {
|
|||
* @param n initial count
|
||||
*/
|
||||
public CountedObject(T o, int n) {
|
||||
assert o!=null : "Can not create counted object over null";
|
||||
mObject = o;
|
||||
mCounter = n;
|
||||
}
|
||||
|
|
@ -40,11 +42,18 @@ public class CountedObject<T> {
|
|||
public void increment(int n) { mCounter+=n; }
|
||||
public void decrement() { mCounter--; }
|
||||
public void decrement(int n) { mCounter -= n; }
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) return true;
|
||||
if ( ! ( o instanceof CountedObject )) return false;
|
||||
return mObject.equals(o);
|
||||
if ( ! ( o instanceof CountedObject ) ) return false;
|
||||
if ( ((CountedObject)o).mObject.getClass() != this.mObject.getClass() ) return false;
|
||||
return mObject.equals(((CountedObject<T>)o).getObject());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return mObject.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ package org.broadinstitute.sting.utils;
|
|||
*/
|
||||
public class CountedObjectComparatorAdapter<T> implements java.util.Comparator<CountedObject<T>> {
|
||||
|
||||
private java.util.Comparator<T> mComp;
|
||||
private java.util.Comparator<? super T> mComp;
|
||||
|
||||
/** Initializes comparator adapter with a comparator for objects of trype T */
|
||||
public CountedObjectComparatorAdapter(java.util.Comparator<T> adaptee) {
|
||||
public CountedObjectComparatorAdapter(java.util.Comparator<? super T> adaptee) {
|
||||
mComp = adaptee;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue