Determining the density of states for classical statistical models by a flat-histogram random walk☆