当前位置: 首页>>代码示例>>Java>>正文


Java THashSet.contains方法代码示例

本文整理汇总了Java中gnu.trove.set.hash.THashSet.contains方法的典型用法代码示例。如果您正苦于以下问题:Java THashSet.contains方法的具体用法?Java THashSet.contains怎么用?Java THashSet.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.set.hash.THashSet的用法示例。


在下文中一共展示了THashSet.contains方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: _escapeSpecialCharacters

import gnu.trove.set.hash.THashSet; //导入方法依赖的package包/类
private String _escapeSpecialCharacters(String s, THashSet<Character> specialCharacters) {
	_escapedString = new StringBuilder();
	for (int i = 0; i < s.length(); i++) {
		char character = s.charAt(i);
		if (specialCharacters.contains(character)) {
			_escapedString.append("\\" + character);
		}
		else {
			_escapedString.append(character);
		}
	}
	return _escapedString.toString();
}
 
开发者ID:tolgayilmaz86,项目名称:Common-Java-Utilities,代码行数:14,代码来源:RegExpBuilder.java

示例2: defaultIntersection

import gnu.trove.set.hash.THashSet; //导入方法依赖的package包/类
public static VarSet defaultIntersection (VarSet v1, VarSet v2)
{// Grossly inefficient implementation
  THashSet hset = new THashSet (v1);
  hset.retainAll (v2);
  Variable[] ret = new Variable [hset.size ()];

  int vai = 0;
  for (int vi = 0; vi < v1.size(); vi++) {
    Variable var = v1.get (vi);
    if (hset.contains (var)) { ret[vai++] = var; }
  }

  return new HashVarSet (ret);
}
 
开发者ID:iamxiatian,项目名称:wikit,代码行数:15,代码来源:Utils.java

示例3: calc

import gnu.trove.set.hash.THashSet; //导入方法依赖的package包/类
public float calc(THashSet<Object> s1, THashSet<Object> s2) {
    int com = 0;
    if (s1 == null || s2 == null)
        return 0;
    TObjectHashIterator<Object> it = s1.iterator();
    for ( int i = s1.size(); i-- > 0; ) {
        Object v = it.next();
        if(s2.contains(v))
            com++;
    }
    float sim = ((float) com)/(s1.size()+s2.size()-com);
    return sim;
}
 
开发者ID:FudanNLP,项目名称:fnlp,代码行数:14,代码来源:JaccardSimilarity.java

示例4: isContain

import gnu.trove.set.hash.THashSet; //导入方法依赖的package包/类
public static int isContain(THashSet<String> set,
		ArrayList<String> subwords) {
	int i = 0;
	for(String s: subwords){
		if(set.contains(s))
			i++;
	}
	return i;
}
 
开发者ID:FudanNLP,项目名称:fnlp,代码行数:10,代码来源:MyCollection.java

示例5: load

import gnu.trove.set.hash.THashSet; //导入方法依赖的package包/类
/**
 * Add the properties from the reader to this
 * UberProperties.
 *
 * @param reader Reader containing properties.
 * @param add whether parameters should add to parameters with the same name or replace them.
 * @throws IOException if an error occurs when reading.
 *
 * @since 64bitlabsutils 1.07.01
 */
public void load(Reader reader, boolean add) throws IOException {
	PropertiesLexer lex = new PropertiesLexer(reader);
	PropertiesToken t;
	THashSet<String> names = new THashSet<>();
	StringBuffer comment = new StringBuffer();
	boolean foundComment = false;
	StringBuffer name = new StringBuffer();
	StringBuffer value = new StringBuffer();
	boolean atStart = true;
	String lastSeparator = null;
	while ((t = lex.getNextToken()) != null){
		if (t.getID() == PropertiesToken.COMMENT){
			int start = 1;
			String commentText = t.getContents();
			if (commentText.startsWith("# ")) start = 2;
			comment.append(commentText.substring(start, commentText.length()));
			comment.append("\n");
			lex.getNextToken();
			foundComment = true;
		} else if (t.getID() == PropertiesToken.NAME){
			if (atStart){
				setComment(comment.toString());
				comment.setLength(0);
				atStart = false;
			}
			name.append(t.getContents());
		} else if (t.getID() == PropertiesToken.VALUE){
			if (atStart){
				setComment(comment.toString());
				comment.setLength(0);
				atStart = false;
			}
			value.append(t.getContents());
		} else if (t.getID() == PropertiesToken.SEPARATOR){
			lastSeparator = t.getContents();
		} else if (t.getID() == PropertiesToken.END_LINE_WHITE_SPACE){
			if (atStart){
				setComment(comment.toString());
				comment.setLength(0);
				atStart = false;
			}
			String stName = unescape(name.toString());
			String stValue = unescape(value.toString());
			if (lastSeparator != null || stName.length() > 0 || stValue.length() > 0 ){
				if (add || names.contains(stName)){
					addProperty(stName, stValue);
				} else {
					setProperty(stName, stValue);
					names.add(stName);
				}
				if (foundComment) setComment(stName, unescape(comment.toString()));
			}
			comment.setLength(0);
			name.setLength(0);
			value.setLength(0);
			foundComment = false;
			lastSeparator = null;
		}
	}
}
 
开发者ID:tolgayilmaz86,项目名称:Common-Java-Utilities,代码行数:71,代码来源:UberProperties.java

示例6: update

import gnu.trove.set.hash.THashSet; //导入方法依赖的package包/类
int update(String[] toks) throws IOException {
	if(toks==null)
		return 0;
	THashSet<String> newdict = new THashSet<String>();
	String nowords = "";
	int count = 0;
	for(int i=0;i<toks.length;i++){//取得包含新词的最长子串
		if(Chars.isLetterOrDigitOrPunc(toks[i]))
			continue;

		if(!dict.contains(toks[i])&&!tempdict.contains(toks[i])){
			nowords += "" + toks[i];
			count++;
		}else{
			if(nowords.length()>0){
				System.out.println(nowords);
				newdict.add(nowords.trim());
				nowords = "";
			}
		}
	}


	TObjectHashIterator<String> it = newdict.iterator();
	while(it.hasNext()){
		String s = it.next();
		if(nodict.contains(s))
			continue;
		System.out.println("搜索: "+s);
		THashSet<String> sset = getNewWords(s);
		if(sset==null||sset.size()==0)
			continue;
		System.out.println(sset);
		tempdict.addAll(sset);
		if(!sset.contains(s)&&!nodict.contains(s)){
			nodict.add(s);
			bwNo.write(s);
			bwNo.write("\n");
		}

	}
	bwNew.flush();
	bwNo.flush();
	return count;
}
 
开发者ID:FudanNLP,项目名称:fnlp,代码行数:46,代码来源:RLSeg.java


注:本文中的gnu.trove.set.hash.THashSet.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。