After being stopped by the police, a person will typically be questioned. During this frisk, if they feel something that may be a weapon, they may remove it from the suspect for further examination. However, they are not entitled to remove items from person's pockets that do not appear to be weapons, even if they believe that the items are contraband. Anything you say can and will be used against you in a court of law. You have the right to an attorney.
Reality is a bit more complicated.
An arrest occurs when a person no longer reasonably expects that he is free to leave. You can refuse the police permission to conduct a search. Remember this - the only reason the police officer wants to perform a search is for evidence of criminal activity, and the fact that he is asking reflects an expectation that he will find some. If the police officer has the legal right to perform the search, he will do so whether or not you agree. However, if he does not have the legal right to perform a search, your consent gives him that right.