refactoring

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@578 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Tom Copeland
2002-07-31 18:48:23 +00:00
parent 80734fe051
commit ff090a1e6e
2 changed files with 12 additions and 8 deletions

View File

@ -41,7 +41,9 @@ public class GST {
Occurrences newOccurrences = new Occurrences();
for (Iterator i = occurrences.getTiles(); i.hasNext();) {
Tile tile = (Tile)i.next();
expandTile(newOccurrences, tile );
if (!newOccurrences.containsAnyTokensIn(tile)) {
expandTile(newOccurrences, tile );
}
}
occurrences = newOccurrences;
}
@ -52,13 +54,6 @@ public class GST {
}
private void expandTile(Occurrences newOcc, Tile tile) {
// make sure the tile doesn't have anything that's used already
for (Iterator i = tile.getTokens().iterator(); i.hasNext();) {
if (newOcc.contains((Token)i.next())) {
return;
}
}
for (Iterator i = occurrences.getOccurrences(tile); i.hasNext();) {
Occurrence occ = (Occurrence)i.next();
TokenSet tokenSet = tokenSets.getTokenSet(occ);

View File

@ -61,6 +61,15 @@ public class Occurrences {
return false;
}
public boolean containsAnyTokensIn(Tile tile) {
for (Iterator i = tile.getTokens().iterator(); i.hasNext();) {
if (contains((Token)i.next())) {
return true;
}
}
return false;
}
public boolean contains(Token tok) {
for (Iterator i = occurrences.keySet().iterator(); i.hasNext();) {
Tile tile = (Tile)i.next();