title: Merge a data.table with ranges (intervals) with another with single values
body: <p>I have two data.tables, one with a range and one with a value:</p>
  
  <pre><code>x = data.table(start = c(5,31,22,16), end = c(8,50,25,18))
  y = data.table(val = c(40, 17, 7, 23))
  
  x
  #   start end
  #1:     5   8
  #2:    31  50
  #3:    22  25
  #4:    16  18
  
  y
  #   val
  #1:  40
  #2:  17
  #3:   7
  #4:  23
  </code></pre>
  
  <p>The need to be merged based on the overlaps (required result):</p>
  
  <pre><code>res = data.table(start = c(5,31,22,16), end = c(8,50,25,18), val = c(7, 40, 23, 17))
  
  res
  #   start end val
  #1:     5   8   7
  #2:    31  50  40
  #3:    22  25  23
  #4:    16  18  17
  </code></pre>
  
  <p>The <code>foverlaps</code> {data.table} function requires both data.tables to have an interval. The <code>findInterval</code> {base} function requires a vector of non-decreasing breakpoints. </p>
  
  <p>How can this merge be done (in data.table) ?</p>