java.lang.Object
net.i2p.router.networkdb.kademlia.StoreJob.LeaseComparator
All Implemented Interfaces:
Serializable, Comparator<Lease>
Enclosing class:
StoreJob

private static class StoreJob.LeaseComparatorextends Object implements Comparator<Lease>, Serializable
Compare leases by XOR distance to a target hash.
  • Field Details

    • _base

      private final byte[] _base
      The target hash for distance comparison.
  • Constructor Details

    • LeaseComparator

      public LeaseComparator(Hash target)
      Create a comparator for a target hash.
      Parameters:
      target - key to compare distances with
  • Method Details

    • compare

      public int compare(Lease lhs, Lease rhs)
      Compare two leases by XOR distance to the target.
      Specified by:
      compare in interface Comparator<Lease>
      Parameters:
      lhs - first lease to compare
      rhs - second lease to compare
      Returns:
      negative if lhs is closer, positive if rhs is closer, 0 if equal