@SuppressWarnings({"SimplifiableIfStatement"}) public boolean equals(Object other) { if (!(other instanceof Set)) { return false; } Set that = (Set) other; if (that.size() != this.size()) { return false; } return containsAll(that); }
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; } }
/** * 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; }
/** * Expands the set to accommodate new values. * * @param newCapacity an <code>int</code> value */ @SuppressWarnings({"unchecked"}) protected void rehash(int newCapacity) { int oldCapacity = _set.length; int oldSize = size(); Object oldSet[] = _set; _set = new Object[newCapacity]; Arrays.fill(_set, FREE); int count = 0; for (int i = oldCapacity; i-- > 0;) { E o = (E) oldSet[i]; if (o != FREE && o != REMOVED) { int index = insertKey(o); if (index < 0) { // everyone pays for this because some people can't RTFM throwObjectContractViolation(_set[(-index - 1)], o, size(), oldSize, oldSet); } // count++; } } // Last check: size before and after should be the same reportPotentialConcurrentMod(size(), oldSize); }
/** * Returns a new array containing the objects in the set. * * @return an <code>Object[]</code> value */ @SuppressWarnings({"unchecked"}) public Object[] toArray() { Object[] result = new Object[size()]; forEach(new ToObjectArrayProceedure(result)); return result; }
/** * Returns a typed array of the objects in the set. * * @param a an <code>Object[]</code> value * @return an <code>Object[]</code> value */ @SuppressWarnings({"unchecked"}) public <T> T[] toArray(T[] a) { int size = size(); if (a.length < size) { a = (T[]) Array.newInstance(a.getClass().getComponentType(), size); } forEach(new ToObjectArrayProceedure(a)); // If this collection fits in the specified array with room to // spare (i.e., the array has more elements than this // collection), the element in the array immediately following // the end of the collection is set to null. This is useful in // determining the length of this collection only if the // caller knows that this collection does not contain any null // elements.) if (a.length > size) { a[size] = null; } return a; }
/** * 设置词典 * @param newset */ public void setDictionary(THashSet<String> newset) { if(newset.size()==0) return; ArrayList<String> al = new ArrayList<String>(); MyCollection.TSet2List(newset, al); Dictionary dict = new Dictionary(); dict.addSegDict(al); setDictionary(dict); }
System.out.println("搜索: "+s); THashSet<String> sset = getNewWords(s); if(sset==null||sset.size()==0) continue; System.out.println(sset);
@Override public int size() { return delegate.size(); }
@SuppressWarnings({"SimplifiableIfStatement"}) public boolean equals(Object other) { if (!(other instanceof Set)) { return false; } Set that = (Set) other; if (that.size() != this.size()) { return false; } return containsAll(that); }
int getNumUniqueClades(TreePairMerger pair) { int t1Clades = pair.t1.vertexCount() - treeToTaxa.get(pair.t1).size(); int t2Clades = pair.t2.vertexCount() - treeToTaxa.get(pair.t2).size(); int t1BackboneClades = pair.t1prunedVertexCount - pair.commonLeafes.size(); int t2BackboneClades = pair.t2prunedVertexCount - pair.commonLeafes.size(); return (t1Clades - t1BackboneClades) + (t2Clades - t2BackboneClades); }
@Override @SuppressWarnings({"SimplifiableIfStatement"}) public boolean equals(Object other) { if (!(other instanceof Set)) { return false; } Set that = (Set) other; if (that.size() != this.size()) { return false; } return containsAll(that); }
@SuppressWarnings({"SimplifiableIfStatement"}) public boolean equals(Object other) { if (!(other instanceof Set)) { return false; } Set that = (Set) other; if (that.size() != this.size()) { return false; } return containsAll(that); }
/** * Returns a new array containing the objects in the set. * * @return an <code>Object[]</code> value */ @SuppressWarnings({"unchecked"}) public Object[] toArray() { Object[] result = new Object[size()]; forEach(new ToObjectArrayProceedure(result)); return result; }
/** * Returns a new array containing the objects in the set. * * @return an <code>Object[]</code> value */ @SuppressWarnings({"unchecked"}) public Object[] toArray() { Object[] result = new Object[size()]; forEach(new ToObjectArrayProceedure(result)); return result; }
/** * Returns a new array containing the objects in the set. * * @return an <code>Object[]</code> value */ @SuppressWarnings({"unchecked"}) public Object[] toArray() { Object[] result = new Object[size()]; forEach( new ToObjectArrayProceedure( result ) ); return result; }
/** * Returns a new array containing the objects in the set. * * @return an <code>Object[]</code> value */ @Override @SuppressWarnings({"unchecked"}) public Object[] toArray() { Object[] result = new Object[size()]; forEach(new ToObjectArrayProceedure(result)); return result; }