Posted on 2008-09-23 11:44
jr4e 阅读(127)
评论(0) 编辑 收藏 所属分类:
Eclipse
public class NameManager implements INameManager {
private Set namePool = new HashSet();
public String generateName(String nameType) {
if (!namePool.contains(nameType)) {
namePool.add(nameType);
return nameType;
}
int i = 1;
while (namePool.contains(nameType + i)) {
i++;
}
namePool.add(nameType + i);
return nameType + i;
}