Skip to content

Instantly share code, notes, and snippets.

@pocari
Created September 15, 2013 02:41
Show Gist options
  • Save pocari/6567595 to your computer and use it in GitHub Desktop.
Save pocari/6567595 to your computer and use it in GitHub Desktop.
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