/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* std::vector<>, which requires it to be Assignable.)
*/
-#ifndef FOLLY_SORTED_VECTOR_TYPES_H_
-#define FOLLY_SORTED_VECTOR_TYPES_H_
+#pragma once
#include <algorithm>
#include <initializer_list>
size_type max_size() const { return m_.cont_.max_size(); }
bool empty() const { return m_.cont_.empty(); }
void reserve(size_type s) { return m_.cont_.reserve(s); }
+ void shrink_to_fit() { m_.cont_.shrink_to_fit(); }
size_type capacity() const { return m_.cont_.capacity(); }
std::pair<iterator,bool> insert(const value_type& value) {
size_type max_size() const { return m_.cont_.max_size(); }
bool empty() const { return m_.cont_.empty(); }
void reserve(size_type s) { return m_.cont_.reserve(s); }
+ void shrink_to_fit() { m_.cont_.shrink_to_fit(); }
size_type capacity() const { return m_.cont_.capacity(); }
std::pair<iterator,bool> insert(const value_type& value) {
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;
}
//////////////////////////////////////////////////////////////////////
}
-
-#endif
-