Brunet.Symphony.StructuredNearConnectionOverlord.CheckForNearerNeighbors C# (CSharp) Метод

CheckForNearerNeighbors() защищенный Метод

protected CheckForNearerNeighbors ( ConnectionList structs, IEnumerable neighbors, Address &nltarget, Address &nrtarget ) : void
structs ConnectionList
neighbors IEnumerable
nltarget Address
nrtarget Address
Результат void
    protected void CheckForNearerNeighbors(ConnectionList structs,
        IEnumerable neighbors, out Address nltarget, out Address nrtarget)
    {

      BigInteger ldist = null;
      BigInteger rdist = null;
      nltarget = null;
      nrtarget = null;
      AHAddress local = (AHAddress)_node.Address;
      foreach(NodeInfo ni in neighbors) {
        if( !( _node.Address.Equals(ni.Address) ||
               structs.Contains(ni.Address) ) ) {
          AHAddress adr = (AHAddress)ni.Address;
          int n_left = structs.LeftInclusiveCount(_node.Address, adr);
          int n_right = structs.RightInclusiveCount(_node.Address, adr);
          if( n_left < DESIRED_NEIGHBORS || n_right < DESIRED_NEIGHBORS ) {
            //We should connect to this node! if we are not already:
            BigInteger adr_dist = local.LeftDistanceTo(adr);
            if( ( null == ldist ) || adr_dist < ldist ) {
              ldist = adr_dist;
              nltarget = adr;
            }
            adr_dist = local.RightDistanceTo(adr);
            if( ( null == rdist ) || adr_dist < rdist ) {
              rdist = adr_dist;
              nrtarget = adr;
            }
          }
        }
      }
    }