我有一個有趣的問題排序Java對象,並根據屬性
這裏找到相對位置是基於序列和窗口對象結構
public class Testdata {
//Which is a consecutive running number i.e 1,2,3..etc
private int sequence;
//classified based on this again any random numbers
private int window;
//need to calculate
private int windowposition;
}
現在,我需要得到windowposition在相對於窗口
測試數據
所以對於TESTDATA序列/窗口
1/2
2/3
3/2
4/3
5/3
期望輸出
sequence/window : window position would be (in the same order)
1/2 : 1
2/3 : 1
3/2 : 2
4/3 : 2
5/3 : 3
更新:
是真的,我已經下面爲了實現可比性和排序的名單到現在
1/2
3/2
2/3
4/3
5/3
我怎麼計算與其窗口相關的每個元素的windowposition
你需要windowsposition = sumOfPreviousWindowById(窗口)+ 1嗎? – neworld 2012-08-16 12:24:56
什麼問題? – 2012-08-16 12:25:20
@ngmiceli仔細閱讀這個問題,你會注意到,如果你仍然沒有「現在基於序列和窗口,我將需要派生窗口相對於窗口」 – Sudhakar 2012-08-16 13:16:53