Rewrite this function as DB query?
Posted
by
aLk
on Stack Overflow
See other posts from Stack Overflow
or by aLk
Published on 2011-01-03T03:44:48Z
Indexed on
2011/01/03
3:54 UTC
Read the original article
Hit count: 227
I'm cleaning up my code, should i change the following function to a MySQL query? If so what would be a nice MySQL function to achieve this functionality?
public ArrayList getNewTitles(ArrayList candidateTitles, ArrayList existingTitles) {
ArrayList newTitles = new ArrayList();
Movie movie = new Movie();
boolean isNew = true;
for(int i=0; i<candidateTitles.size(); i++) {
for(int j=0; j<existingTitles.size(); j++) {
movie = (Movie)existingTitles.get(j);
if(((String)candidateTitles.get(i)).equals(movie.getRawTitle())) {
isNew = false;
}
}
if(isNew == true) {
System.out.println("newTitle for crawling: " + (String)candidateTitles.get(i));
newTitles.add((String)candidateTitles.get(i));
}
else {
System.out.println("candidate binned: " + (String)candidateTitles.get(i));
}
isNew = true;
}
return newTitles;
}
© Stack Overflow or respective owner