I am somewhat new to evolutionary biology, having studied it on my free time as a computer science student. There is one particular thing that has always bothered me for which I have not seen a good treatment, relating to adaptations to the environment with respect to genetic diversity. If it is possible for a population to adapt to rapid environmental changes, and they don't have an adaptation for dealing with change directly (such as a complex brain), it seems to me that every generation must have present within them almost every possible environmental adaptation that the population is capable of expressing (including many irrelevant ones and a few relevant to the particular environmental challenge). Otherwise, it may take too many generations to deal with a change, which may be disastrous for the population.
So my question would be: how does an evolutionary biologist explain the mechanics behind the ability for a population to adapt quickly? Are most environmental changes slow or gradual enough that the population has a few generations to happen upon the mutations that will allow it to survive, and have generally been successful in this regard for 3.5 billion years? Or, are a large majority of possible adaptations present in almost every generation, and just serve no purpose or advantage for most of the population if the provided "benefit" is unneeded (i.e., are effectively neutral)? Or something in between?