Class CacheableItemDistanceModel<I>

java.lang.Object
es.uam.eps.ir.relison.links.recommendation.features.CacheableItemDistanceModel<I>
Type Parameters:
I - type of the items.
All Implemented Interfaces:
es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I>

public class CacheableItemDistanceModel<I>
extends java.lang.Object
implements es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I>
Item distance model which stores the distances in a cache.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.Map<I,​java.util.Map<I,​java.lang.Double>> cache
    The item distance cache.
    private es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I> model
    The current item distance model.
    private boolean symmetric
    True if distances are symmetric (d(a,b)=d(b,a)), false otherwise.
  • Constructor Summary

    Constructors 
    Constructor Description
    CacheableItemDistanceModel​(es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I> model, boolean symmetric)
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    java.util.function.ToDoubleFunction<I> dist​(I i)  
    double dist​(I i, I j)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • cache

      private final java.util.Map<I,​java.util.Map<I,​java.lang.Double>> cache
      The item distance cache.
    • model

      private final es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I> model
      The current item distance model.
    • symmetric

      private final boolean symmetric
      True if distances are symmetric (d(a,b)=d(b,a)), false otherwise.
  • Constructor Details

    • CacheableItemDistanceModel

      public CacheableItemDistanceModel​(es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I> model, boolean symmetric)
      Constructor.
      Parameters:
      model - a distance model between items.
      symmetric - true if d(a,b)=d(b,a), false otherwise.
  • Method Details

    • dist

      public java.util.function.ToDoubleFunction<I> dist​(I i)
      Specified by:
      dist in interface es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I>
    • dist

      public double dist​(I i, I j)
      Specified by:
      dist in interface es.uam.eps.ir.ranksys.novdiv.distance.ItemDistanceModel<I>