Brunet.Services.MapReduce.MapReduceBoundedBroadcast.GenerateTreeInRange C# (CSharp) Method

GenerateTreeInRange() private method

private GenerateTreeInRange ( AHAddress start, AHAddress end, List cons, bool left, MapReduceArgs mr_args ) : List
start Brunet.Symphony.AHAddress
end Brunet.Symphony.AHAddress
cons List
left bool
mr_args MapReduceArgs
return List
    private List<MapReduceInfo> GenerateTreeInRange(AHAddress start, AHAddress end, List<Connection> cons, bool left, MapReduceArgs mr_args) {
      //Divide the range and trigger bounded broadcasting again in divided range starting with neighbor.
      //Deivided ranges are (start, n_1), (n_1, n_2), ... , (n_m, end)
      AHAddress this_minus2 = new AHAddress(_this_addr.ToBigInteger()-2);
      AHAddress this_plus2 = new AHAddress(_this_addr.ToBigInteger()+2);
      List<MapReduceInfo> retval = new List<MapReduceInfo>();
      if (cons.Count != 0) //make sure if connection list is not empty!
      {
        //con_list is sorted.
        AHAddress last;
        if (left) {
          last = end;
        }
        else {
          last = start;
        }
        string rg_start, rg_end;
        //the first element of cons is the nearest.
        //Let's start with the farthest neighbor first.
        for (int i = (cons.Count-1); i >= 0; i--) {
          ArrayList gen_arg = new ArrayList();
          Connection next_c = cons[i];
          AHAddress next_addr = (AHAddress)next_c.Address;
          ISender sender = next_c.State.Edge;
          if (i==0) {  // The last bit
            if (left) {
              // the left nearest neighbor 
              rg_start = this_plus2.ToString();
              rg_end = last.ToString();
            }
            else {
              // the right nearest neighbor
              rg_start = last.ToString();
              rg_end = this_minus2.ToString();
            }
          }
          else {
            if (left) { //left connections
              rg_start = next_addr.ToString();
              rg_end = last.ToString();
            }
            else {  //right connections
              rg_start = last.ToString();
              rg_end = next_addr.ToString();
            }
          }
          gen_arg.Add(rg_start);
          gen_arg.Add(rg_end);
          MapReduceInfo mr_info = new MapReduceInfo( sender,
           		                              new MapReduceArgs(this.TaskName,
          				               	             mr_args.MapArg,
          							     gen_arg,
          							     mr_args.ReduceArg));
          Log("{0}: {1}, adding address: {2} to sender list, range start: {3}, range end: {4}",
          			    this.TaskName, _node.Address, next_c.Address,
          			    gen_arg[0], gen_arg[1]);
          if (left) {
            last = new AHAddress(next_addr.ToBigInteger()-2);
          }
          else {
            last = new AHAddress(next_addr.ToBigInteger()+2);
          }
          retval.Add(mr_info);
        }
      }
      return retval;
    }    
    /**