-
-
Save pocari/6567595 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String checkDuplicate2(TableMessage tm) { | |
int NUM = 5; | |
//重複チェックなので、基準値は最後から2番めの要素(NUM-1)までチェック | |
for (int i = 0; i < NUM - 1; i++) { | |
//基準値までの日付はすでにチェック済みなので、基準値の次の要素からチェックする | |
for (int j = i + 1; j < NUM; j++) { | |
if (tm.getRecord(i, "key").equals(tm.getRecord(j, "key"))) { | |
String result = tm.getRecord(i, "num") + ", " + tm.getRecord(j, "num"); | |
//重複が見つかった場合は残りの要素からその日付の行があるか調べる | |
for (int rest = j + 1; rest < NUM; rest++) { | |
if (tm.getRecord(i, "key").equals(tm.getRecord(rest, "key"))) { | |
result += ", " + tm.getRecord(rest, "num"); | |
} | |
} | |
//最初の重複パターンのみでいいので、ここで返す | |
return result; | |
} | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment