當前位置: 首頁>>代碼示例>>Java>>正文


Java Doubles.compare方法代碼示例

本文整理匯總了Java中com.google.common.primitives.Doubles.compare方法的典型用法代碼示例。如果您正苦於以下問題:Java Doubles.compare方法的具體用法?Java Doubles.compare怎麽用?Java Doubles.compare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.primitives.Doubles的用法示例。


在下文中一共展示了Doubles.compare方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compareTo

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public int compareTo(PlanPath o) {
	int res = -1*Doubles.compare(getCost(), o.getCost());
	if(res==0)
		res = getSelectTable().getName().compareTo(o.getSelectTable().getName());
	
	return res;
}
 
開發者ID:ajoabraham,項目名稱:hue,代碼行數:9,代碼來源:PlanPath.java

示例2: equals

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof City)) return false;

    City city = (City) o;

    if (Doubles.compare(city.averageRainfall, averageRainfall) != 0) return false;
    if (population != city.population) return false;
    if (climate != city.climate) return false;
    if (name != null ? !name.equals(city.name) : city.name != null) return false;
    return zipCode != null ? zipCode.equals(city.zipCode) : city.zipCode == null;
}
 
開發者ID:wsldl123292,項目名稱:testeverything,代碼行數:14,代碼來源:City.java

示例3: equals

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof Stock)) return false;

    Stock stock = (Stock) o;

    if (Doubles.compare(stock.price, price) != 0) return false;
    return symbol != null ? symbol.equals(stock.symbol) : stock.symbol == null;
}
 
開發者ID:wsldl123292,項目名稱:testeverything,代碼行數:11,代碼來源:Stock.java

示例4: compare

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public int compare(CapFloorIbor o1,  CapFloorIbor o2) {
  int a = Doubles.compare(o1.getStrike(), o2.getStrike());
  if (a != 0) {
    return a;
  }
  return Doubles.compare(o1.getFixingTime(), o2.getFixingTime());
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:9,代碼來源:MultiCapFloorPricer.java

示例5: verifyCandidates

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private final Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
  numSimilarities = numCandidates;
  // add forgetting factor e^(-lambda*delta_T) and filter candidates < theta
  for (Iterator<Long2DoubleMap.Entry> it = accumulator.long2DoubleEntrySet().iterator(); it.hasNext();) {
    Long2DoubleMap.Entry e = it.next();
    final long deltaT = v.timestamp() - e.getLongKey();
    e.setValue(e.getDoubleValue() * forgettingFactor(lambda, deltaT));
    if (Doubles.compare(e.getDoubleValue(), theta) < 0)
      it.remove();
  }
  numMatches += accumulator.size();
  return accumulator;
}
 
開發者ID:gdfm,項目名稱:sssj,代碼行數:14,代碼來源:INVIndex.java

示例6: generateCandidates

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private final void generateCandidates(final Vector v, final boolean addToIndex) {
  for (Int2DoubleMap.Entry e : v.int2DoubleEntrySet()) {
    final int dimension = e.getIntKey();
    final double queryWeight = e.getDoubleValue();
    StreamingPostingList list;
    if ((list = idx.get(dimension)) != null) {
      for (StreamingPostingListIterator listIter = list.reverseIterator(); listIter.hasPrevious();) {
        final PostingEntry pe = listIter.previous();
        final long targetID = pe.getID();

        // time filtering
        final long deltaT = v.timestamp() - targetID;
        if (Doubles.compare(deltaT, tau) > 0) {
          listIter.next(); // back off one position
          size -= listIter.nextIndex(); // update index size before cutting
          listIter.cutHead(); // prune the head
          break;
        }
        numPostingEntries++;

        final double targetWeight = pe.getWeight();
        final double additionalSimilarity = queryWeight * targetWeight * forgettingFactor(lambda, deltaT);
        accumulator.addTo(targetID, additionalSimilarity);
      }
    } else {
      if (addToIndex) {
        list = new StreamingPostingList();
        idx.put(dimension, list);
      }
    }
    if (addToIndex) {
      list.add(v.timestamp(), queryWeight);
      size++;
    }
  }
  numCandidates += accumulator.size();
}
 
開發者ID:gdfm,項目名稱:sssj,代碼行數:38,代碼來源:StreamingINVIndex.java

示例7: verifyCandidates

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
private final void verifyCandidates(final Vector v) {
  numSimilarities = numCandidates;
  // filter candidates < theta
  for (Iterator<Long2DoubleMap.Entry> it = accumulator.long2DoubleEntrySet().iterator(); it.hasNext();)
    if (Doubles.compare(it.next().getDoubleValue(), theta) < 0)
      it.remove();
  numMatches += accumulator.size();
}
 
開發者ID:gdfm,項目名稱:sssj,代碼行數:9,代碼來源:StreamingINVIndex.java

示例8: initOrderingLng

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Initializes the field {@link #orderingLng} if it is {@code null}.
 */
private void initOrderingLng() {
    if (orderingLng == null) {
        orderingLng = new Ordering<Node>() {

            @Override
            public int compare(Node left, Node right) {
                return Doubles.compare(left.getLongitude(),
                        right.getLongitude());
            }
        };
    }
}
 
開發者ID:dhasenfratz,項目名稱:hRouting_Android,代碼行數:16,代碼來源:TreeBuilder.java

示例9: initOrderingLat

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Initializes the field {@link #orderingLat} if it is {@code null}.
 */
private void initOrderingLat() {
    if (orderingLat == null) { // Lazy initialization
        orderingLat = new Ordering<Node>() {
            @Override
            public int compare(Node left, Node right) {
                return Doubles.compare(left.getLatitude(),
                        right.getLatitude());
            }
        };
    }
}
 
開發者ID:dhasenfratz,項目名稱:hRouting_Android,代碼行數:15,代碼來源:TreeBuilder.java

示例10: findNearestNode

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
/**
 * Recursive Nearest Node Search on kd-tree.
 *
 * @param current the current
 * @param search the search
 * @param depth the depth
 * @return the node
 */
private Node findNearestNode(Node current, Node search, int depth) {
    // Go down tree
    int direction;
    if (depth % 2 == 0) {
        direction = Doubles.compare(search.latitude, current.latitude);
    } else {
        direction = Doubles.compare(search.longitude, current.longitude);
    }
    int next = direction < 0 ? kdLeft[current.id - 1]
            : kdRight[current.id - 1];
    int other = direction < 0 ? kdRight[current.id - 1]
            : kdLeft[current.id - 1];

    // Go to a leaf node and mark it as best!
    Node best = next == NULL_NODE ? current : findNearestNode(
            nodeArray[next - 1], search, depth + 1);

    // Compare current node to best node
    if (current.squaredDistance(search) < best.squaredDistance(search)) {
        best = current; // Set best as required
    }

    if (other != NULL_NODE) {
        if (current.axisSquaredDistance(search, depth % 2) < best
                .axisSquaredDistance(search, depth % 2)) {
            Node possibleBest = findNearestNode(nodeArray[other - 1],
                    search, depth + 1);
            if (possibleBest.squaredDistance(search) < best
                    .squaredDistance(search)) {
                best = possibleBest;
            }
        }
    }
    // Go up tree.
    return best;
}
 
開發者ID:dhasenfratz,項目名稱:hRouting_Android,代碼行數:45,代碼來源:Graph.java

示例11: compareTo

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
public int compareTo(ChunkRenderDispatcher.PendingUpload p_compareTo_1_)
{
    return Doubles.compare(this.distanceSq, p_compareTo_1_.distanceSq);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:ChunkRenderDispatcher.java

示例12: compareTo

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
public int compareTo(ChunkCompileTaskGenerator p_compareTo_1_)
{
    return Doubles.compare(this.distanceSq, p_compareTo_1_.distanceSq);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:5,代碼來源:ChunkCompileTaskGenerator.java

示例13: compare

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public int compare(Object o, Object o1)
{
  return Doubles.compare(((Number) o).doubleValue(), ((Number) o1).doubleValue());
}
 
開發者ID:implydata,項目名稱:druid-example-extension,代碼行數:6,代碼來源:ExampleSumAggregatorFactory.java

示例14: compareTo

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public int compareTo(Literal o) {
    Object that = o.getValue();

    // Sort nulls first
    if (_value == null) {
        return that == null ? 0 : -1;
    } else if (that == null) {
        return 1;
    }

    // Optimize for common case where values being compared are of the same type
    Class<?> thisClass = _value.getClass();
    Class<?> thatClass = that.getClass();

    if (!areClassesEqual(thisClass, thatClass)) {
        // Values are of different types
        // If both values are numeric then use numeric comparison regardless of the underlying type (int, double, and so on)
        if (isNumber(thisClass) && isNumber(thatClass)) {
            if (isDouble((Class<? extends Number>) thisClass) || isDouble((Class<? extends Number>) thatClass)) {
                return Doubles.compare(((Number) _value).doubleValue(), ((Number) that).doubleValue());
            } else {
                return Longs.compare(((Number) _value).longValue(), ((Number) that).longValue());
            }
        }

        // Sort by simple class name
        return getComparisonClassName(thisClass).compareTo(getComparisonClassName(thatClass));
    }

    if (Comparable.class.isAssignableFrom(thisClass)) {
        return ((Comparable) _value).compareTo(that);
    }

    // When not comparable, compare the string representations
    try {
        StringBuilder thisStr = new StringBuilder();
        StringBuilder thatStr = new StringBuilder();
        this.appendTo(thisStr);
        o.appendTo(thatStr);
        return thisStr.toString().compareTo(thatStr.toString());
    } catch (IOException e) {
        // Should never happen
        throw Throwables.propagate(e);
    }

}
 
開發者ID:bazaarvoice,項目名稱:emodb,代碼行數:49,代碼來源:LiteralImpl.java

示例15: compare

import com.google.common.primitives.Doubles; //導入方法依賴的package包/類
@Override
public int compare(City city1, City city2) {
       return Doubles.compare(city1.getAverageRainfall(), city2.getAverageRainfall());
}
 
開發者ID:wsldl123292,項目名稱:testeverything,代碼行數:5,代碼來源:CityByRainfall.java


注:本文中的com.google.common.primitives.Doubles.compare方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。