Skip to content

Instantly share code, notes, and snippets.

@juliensimon
Last active August 29, 2015 14:17
Show Gist options
  • Save juliensimon/c53daffee16db0a106a2 to your computer and use it in GitHub Desktop.
Save juliensimon/c53daffee16db0a106a2 to your computer and use it in GitHub Desktop.
public static <T> boolean linearSearch(List<T> list, T t, LinearSearchMode<T> mode) {
if ((list == null) || (t == null)) {
return false;
}
for (int i = 0; i < list.size(); i++) {
if (list.get(i).equals(t)) {
if (mode != null) {
mode.moveElement(list, i);
}
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment