Check distance

How can I iterate through a Vector3 array, and for every Vector3, check to see whether there is a neighbouring one?

So for example if my array is (0,0,0), how can I check if (1,0,0) is there?

By neighbouring, I mean if they were 1,1,1 blocks, they would be touching. So an increase in 1 co-ordinate, but not the others.

To check, I’m using this code. However, I think there is a mistake somewhere, since the if statement does not return true for blocks on there own.

function march(){
var px = false;
var nx = false;
var py = false;
var ny = false;
var pz = false;
var nz = false;

  // for (var xvalue : int in xcoords) {
   for(var i : Vector3 in blocks) 
    {
        // no need to compare twice agains smaller indices, so start at i+1
        for(var j : Vector3 in blocks)  {
          if(j.x-i.x == -1){
          nx= true;
          }
          if(j.x-i.x == 1){
          px = true;
          }
          if(j.y-i.y == -1){
          ny = true;
          }
          if(j.y-i.y == 1){
          nx = true;
          }
          if(j.z-i.z == -1){
          nz = true;
          }
          if(j.z-i.z == 1){
          pz = true;
          }
              if(nx == false && px == false && ny == false && py == false && nz == false && pz == false){
              print ("i is " + i + "j is " + j);

              }
        }
    }
}

Comparing equality between floats is a treacherous thing: it only returns true in some special cases. If you really need to compare to 1, use Mathf.Approximately instead:

   for(var i : Vector3 in blocks){
       // no need to compare twice agains smaller indices, so start at i+1
       for(var j : Vector3 in blocks)  {
          var dif = j - i;
          nx = Mathf.Approximately(dif.x, -1);
          px = Mathf.Approximately(dif.x, 1);
          ny = Mathf.Approximately(dif.y, -1);
          py = Mathf.Approximately(dif.y, 1);
          nz = Mathf.Approximately(dif.z, -1);
          pz = Mathf.Approximately(dif.z, 1);
          if(!nx && !px && !ny && !py && !nz && !pz){
              print ("i is " + i + "j is " + j);
          }
       }
    }