Added O(1) erase(). May have broken edge cases.