Skip to content

Commit

Permalink
修复比较方法的Bug,增加对象相等条件的判断。 Fixed alibaba#11
Browse files Browse the repository at this point in the history
  • Loading branch information
jlusdy committed Mar 4, 2013
1 parent ccafab1 commit e7f75c8
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions src/main/java/com/taobao/profile/analysis/TimeSortData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,72 @@
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
*
*/
package com.taobao.profile.analysis;

import java.util.Stack;

/**
* 可排序数据对象
*
*
* @author shutong.dy
* @since 2012-1-11
*/
public class TimeSortData implements Comparable<TimeSortData> {

private long sum = 0;
private String methodName;
private Stack<Long> valueStack = new Stack<Long>();
private long sum = 0;
private String methodName;
private Stack<Long> valueStack = new Stack<Long>();

/**
* @return the methodName
*/
public String getMethodName() {
return methodName;
}
/**
* @return the methodName
*/
public String getMethodName() {
return methodName;
}

/**
* @param methodName
* the methodName to set
*/
public void setMethodName(String methodName) {
this.methodName = methodName;
}
/**
* @param methodName the methodName to set
*/
public void setMethodName(String methodName) {
this.methodName = methodName;
}

/**
* @return the valueStack
*/
public Stack<Long> getValueStack() {
return valueStack;
}
/**
* @return the valueStack
*/
public Stack<Long> getValueStack() {
return valueStack;
}

/**
* @param useTime
*
*/
public void addStackValue(long useTime) {
valueStack.add(useTime);
sum += useTime;
}
/**
* @param useTime
*/
public void addStackValue(long useTime) {
valueStack.add(useTime);
sum += useTime;
}

/**
* @return the sum
*/
public long getSum() {
return sum;
}
/**
* @return the sum
*/
public long getSum() {
return sum;
}

/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(TimeSortData o) {
if (this.sum > o.sum) {
return -1;
} else {
return 1;
}
}
/*
* (non-Javadoc)
*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
public int compareTo(TimeSortData o) {
if (this.sum > o.sum) {
return -1;
} else if (this.sum < o.sum) {
return 1;
} else {
return 0;
}
}
}

0 comments on commit e7f75c8

Please sign in to comment.