本文整理匯總了Java中com.google.common.collect.Multiset.isEmpty方法的典型用法代碼示例。如果您正苦於以下問題:Java Multiset.isEmpty方法的具體用法?Java Multiset.isEmpty怎麽用?Java Multiset.isEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Multiset
的用法示例。
在下文中一共展示了Multiset.isEmpty方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: compare
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public float compare(Multiset<T> a, Multiset<T> b) {
if (a.isEmpty() && b.isEmpty()) {
return 1.0f;
}
if (a.isEmpty() || b.isEmpty()) {
return 0.0f;
}
final int intersection = intersection(a, b).size();
// ∣a ∩ b∣ / ∣a ∪ b∣
// Implementation note: The size of the union of two sets is equal to
// the size of both sets minus the duplicate elements.
return intersection / (float) (a.size() + b.size() - intersection);
}
示例2: compare
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public float compare(Multiset<T> a, Multiset<T> b) {
if (a.isEmpty() && b.isEmpty()) {
return 1.0f;
}
if (a.isEmpty() || b.isEmpty()) {
return 0.0f;
}
// ∣q ∩ r∣ / min{∣q∣, ∣r∣}
return intersection(a, b).size() / (float) min(a.size(), b.size());
}
示例3: compare
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public float compare(Multiset<T> a, Multiset<T> b) {
if (a.isEmpty() && b.isEmpty()) {
return 1.0f;
}
float maxDistance = (float) sqrt((a.size() * a.size()) + (b.size() * b.size()));
return 1.0f - distance(a, b) / maxDistance;
}
示例4: compare
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public float compare(Multiset<T> a, Multiset<T> b) {
if (a.isEmpty() && b.isEmpty()) {
return 1.0f;
}
if (a.isEmpty() || b.isEmpty()) {
return 0.0f;
}
// 2 * ∣a ∩ b∣ / (∣a∣ + ∣b∣)
return (2.0f * intersection(a, b).size()) / (a.size() + b.size());
}
示例5: compare
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public float compare(Multiset<T> a, Multiset<T> b) {
if (a.isEmpty() && b.isEmpty()) {
return 1.0f;
}
if (a.isEmpty() || b.isEmpty()) {
return 0.0f;
}
return 1.0f - distance(a, b) / (a.size() + b.size());
}
示例6: compare
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
@Override
public float compare(Multiset<T> a, Multiset<T> b) {
if (a.isEmpty() && b.isEmpty()) {
return 1.0f;
}
if (a.isEmpty() || b.isEmpty()) {
return 0.0f;
}
float dotProduct = 0;
float magnitudeA = 0;
float magnitudeB = 0;
for (T entry : union(a, b).elementSet()) {
float aCount = a.count(entry);
float bCount = b.count(entry);
dotProduct += aCount * bCount;
magnitudeA += aCount * aCount;
magnitudeB += bCount * bCount;
}
// a·b / (||a|| * ||b||)
return (float) (dotProduct / (sqrt(magnitudeA) * sqrt(magnitudeB)));
}
示例7: cleanUpForCollectedState
import com.google.common.collect.Multiset; //導入方法依賴的package包/類
/**
* There may be multiple child injectors blacklisting a certain key so only remove the source
* that's relevant.
*/
private void cleanUpForCollectedState(Set<KeyAndSource> keysAndSources) {
synchronized (lock) {
for (KeyAndSource keyAndSource : keysAndSources) {
Multiset<Object> set = backingMap.get(keyAndSource.key);
if (set != null) {
set.remove(keyAndSource.source);
if (set.isEmpty()) {
backingMap.remove(keyAndSource.key);
}
}
}
}
}