You can combine various efficient methods for sampling from discrete distributions with a continuous uniform.
That is, simulate from the integer part Y=[X] of your variable, which has a discrete distribution with probability equal to the probability of being in each interval (such as via the table method - a.k.a. the alias method), and then simply add a random uniform [0,1$, X = Y+U.
In your example, you have Y taking the values 1,2,3 with probability 0.5,0.25 and 0.25 (which is equivalent to sampling 1,1,2,3 with equal probability) and then add a random uniform.
If your "histogram" is really large this can be a very fast approach.
In R you could do a simple (if not especially efficient) version of this via
sample(c(1,1,2,3))+runif(1)
or
sample(c(1,1,2,3),n,replace=TRUE)+runif(n)
and more generally you could use the probability weights argument in sample
.
If you need more speed than this gets you (and for some applications you might, especially with big histograms and really big sample sizes), you can speed up the discrete part quite a bit using approaches mentioned at the link, and programming the workhorse part of that function in a lower level language (in C, say).
That said, even just using the above code with a considerably "bigger" histogram -- dozens to hundreds of bins -- this approach seems - even on my fairly nondescript laptop - to be able to generate a million random values in well under a second, so for many applications this will be fine.