     function phi( key : typekey; lo, up : integer ) : integer;
     var  i : integer;
     begin
     i := trunc( (key-MinKey) * (up-lo+1.0) / (MaxKey-MinKey) ) + lo;
     phi := i;
     if i>up then phi := up
          else if i<lo then phi := lo
     end;
