return end();
}
+ mapped_type& at(const key_type& key) {
+ iterator it = find(key);
+ if (it != end()) {
+ return it->second;
+ }
+ throw std::out_of_range("sorted_vector_map::at");
+ }
+
+ const mapped_type& at(const key_type& key) const {
+ const_iterator it = find(key);
+ if (it != end()) {
+ return it->second;
+ }
+ throw std::out_of_range("sorted_vector_map::at");
+ }
+
size_type count(const key_type& key) const {
return find(key) == end() ? 0 : 1;
}
m[32] = 100.0;
check_invariant(m);
EXPECT_TRUE(m.count(32) == 1);
+ EXPECT_DOUBLE_EQ(100.0, m.at(32));
EXPECT_FALSE(m.find(32) == m.end());
m.erase(32);
EXPECT_TRUE(m.find(32) == m.end());
check_invariant(m);
+ EXPECT_THROW(m.at(32), std::out_of_range);
sorted_vector_map<int,float> m2 = m;
EXPECT_TRUE(m2 == m);
sorted_vector_map<int,int> emptyMap;
EXPECT_TRUE(emptyMap.lower_bound(10) == emptyMap.end());
EXPECT_TRUE(emptyMap.find(10) == emptyMap.end());
+ EXPECT_THROW(emptyMap.at(10), std::out_of_range);
}
TEST(SortedVectorTest, MoveTest) {