X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Fsorted_vector_types.h;h=b9354b10cbb9bdd7e4ae49e7f4b1336c9dfa8b00;hb=7f813725fa5aacead8c001e15a3b4addbd988899;hp=ef451cb2b7559bc238afb15e61bec4419d22dfd8;hpb=7ce33845b2248016806757217e513cce1ee270b6;p=folly.git diff --git a/folly/sorted_vector_types.h b/folly/sorted_vector_types.h index ef451cb2..b9354b10 100644 --- a/folly/sorted_vector_types.h +++ b/folly/sorted_vector_types.h @@ -1,5 +1,5 @@ /* - * 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. @@ -57,8 +57,7 @@ * std::vector<>, which requires it to be Assignable.) */ -#ifndef FOLLY_SORTED_VECTOR_TYPES_H_ -#define FOLLY_SORTED_VECTOR_TYPES_H_ +#pragma once #include #include @@ -552,6 +551,22 @@ public: 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; } @@ -638,6 +653,3 @@ inline void swap(sorted_vector_map& a, ////////////////////////////////////////////////////////////////////// } - -#endif -