@Override public Double get(Object key) { return delegate.get(key); }
@Override public double get(long l) { if (delegate.containsKey(l)) { return delegate.get(l); } else { return dft; } }
/** * Wrap a long-to-double function in another w/ the a different default return value. * @param f The function to wrap. * @param dft The new * @return A function with a different default value. */ @SuppressWarnings("FloatingPointEquality") static Long2DoubleFunction adaptDefaultValue(final Long2DoubleFunction f, final double dft) { if (f.defaultReturnValue() == dft) { return f; } return new DftAdaptingL2DFunction(f, dft); }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Double get(final Object key) { if (key == null) return null; final long k = ((Long) (key)).longValue(); final double v = get(k); return (v != defaultReturnValue() || containsKey(k)) ? Double.valueOf(v) : null; } /**
@Override public boolean containsKey(long l) { return delegate.containsKey(l); }
@Override public int size() { return delegate.size(); }
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Double remove(final Object key) { if (key == null) return null; final long k = ((Long) (key)).longValue(); return containsKey(k) ? Double.valueOf(remove(k)) : null; } /**
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override default Double put(final Long key, final Double value) { final long k = (key).longValue(); final boolean containsKey = containsKey(k); final double v = put(k, (value).doubleValue()); return containsKey ? Double.valueOf(v) : null; } /**
@Override public double applyAsDouble(long operand) { synchronized (sync) { return function.applyAsDouble(operand); } } /**
/** * {@inheritDoc} * * @deprecated Please use the corresponding type-specific method instead. */ @Deprecated @Override public Double apply(final Long key) { synchronized (sync) { return function.apply(key); } } @Override
@Override public boolean containsKey(Object key) { return delegate.containsKey(key); }
@Override public int size() { synchronized (sync) { return function.size(); } } @Override
/** * Compute the DCG of a list of items with respect to a value vector. */ double computeDCG(long[] items, Long2DoubleFunction values) { double gain = 0; int rank = 0; for (long item: items) { final double v = values.get(item); rank++; gain += v * discount.discount(rank); } return gain; }
@Override public int compare(long k1, long k2) { double v1 = vals.containsKey(k1) ? vals.get(k1) : Double.NaN; double v2 = vals.containsKey(k2) ? vals.get(k2) : Double.NaN; return Doubles.compare(v1, v2); } };
@Override public boolean containsKey(final long k) { return function.containsKey(k); } @Override
@Override public double defaultReturnValue() { synchronized (sync) { return function.defaultReturnValue(); } } @Override
@Override public int size() { return function.size(); } @Override
/** * Compute the DCG of a list of items with respect to a value vector. */ double computeDCG(List<Long> items, Long2DoubleFunction values) { double gain = 0; int rank = 0; for (long item: items) { final double v = values.get(item); rank++; gain += v * discount.discount(rank); } return gain; }
@Override public double get(long l) { if (delegate.containsKey(l)) { return delegate.get(l); } else { return dft; } }
@Override public boolean containsKey(final long k) { synchronized (sync) { return function.containsKey(k); } } @Deprecated