public static int getLength(THashSet<String> set) { int i = 0; TObjectHashIterator<String> it = set.iterator(); while(it.hasNext()){ String s = it.next(); if(s.length()>i) i=s.length(); } return i; } /**
public static void TSet2List(THashSet<String> newset, ArrayList<String> al) { TObjectHashIterator<String> it = newset.iterator(); while(it.hasNext()){ String s = it.next(); al.add(s); } } /**
/** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the retain all operation */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll(Collection<?> collection) { boolean changed = false; int size = size(); Iterator<E> it = iterator(); while (size-- > 0) { if (!collection.contains(it.next())) { it.remove(); changed = true; } } return changed; }
/** * 从文件中读取 * @param path 文件路径 * @param tag 词典名 * @throws IOException */ public void load(String path,String tag) throws IOException{ if(path == null) return; dict = MyCollection.loadTSet(path); maxLen = 0; TObjectHashIterator<String> it = dict.iterator(); while(it.hasNext()){ String k = it.next(); if(k.length()>maxLen){ maxLen = k.length(); } } name = tag; }
public void load(String in) throws IOException{ int begin = in.lastIndexOf("\\"); int idx = in.indexOf('-',begin); if(idx==-1) idx = in.indexOf('.',begin); if(idx==-1) idx = in.length(); String pos = in.substring(begin+1,idx); THashSet<String> set = MyCollection.loadTSet(in); TObjectHashIterator<String> it = set.iterator(); while(it.hasNext()){ String s = it.next(); s = s.replaceAll("(\\s| | |\\t)+", ""); if(s.length()==0) continue; add(pos, s); String ss = filter(pos,s); if(ss!=null){ add(pos,ss); } } }
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; } }
TObjectHashIterator<String> it = newdict.iterator(); while(it.hasNext()){ String s = it.next();
@Override public TObjectHashIterator<E> iterator() { return delegate.iterator(); }
@Override public TObjectHashIterator<E> iterator() { return delegate.iterator(); }
/** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the retain all operation */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll(Collection<?> collection) { boolean changed = false; int size = size(); Iterator<E> it = iterator(); while (size-- > 0) { if (!collection.contains(it.next())) { it.remove(); changed = true; } } return changed; }
/** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the retain all operation */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll( Collection<?> collection ) { boolean changed = false; int size = size(); Iterator<E> it = iterator(); while ( size-- > 0 ) { if ( !collection.contains( it.next() ) ) { it.remove(); changed = true; } } return changed; }
/** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the retain all operation */ @Override public boolean retainAll(Collection<?> collection) { boolean changed = false; int size = size(); Iterator<E> it = iterator(); while (size-- > 0) { if (!collection.contains(it.next())) { it.remove(); changed = true; } } return changed; }
/** * Removes any values in the set which are not contained in * <tt>collection</tt>. * * @param collection a <code>Collection</code> value * @return true if the set was modified by the retain all operation */ @SuppressWarnings({"SuspiciousMethodCalls"}) public boolean retainAll(Collection<?> collection) { boolean changed = false; int size = size(); Iterator<E> it = iterator(); while (size-- > 0) { if (!collection.contains(it.next())) { it.remove(); changed = true; } } return changed; }
TObjectHashIterator<Chunk> c = set.iterator(); for (int k = 0, e = set.size(); k < e; ++k) { Chunk chunk = c.next();
TObjectHashIterator<Chunk> c = set.iterator(); for (int k = 0, e = set.size(); k < e; ++k) { Chunk chunk = c.next();