1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <unordered_set> 11 12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 13 // class Alloc = allocator<Value>> 14 // class unordered_set 15 16 // pair<iterator, iterator> equal_range(const key_type& k); 17 18 #include <unordered_set> 19 #include <cassert> 20 21 #include "min_allocator.h" 22 23 int main() 24 { 25 { 26 typedef std::unordered_set<int> C; 27 typedef C::iterator I; 28 typedef int P; 29 P a[] = 30 { 31 P(10), 32 P(20), 33 P(30), 34 P(40), 35 P(50), 36 P(50), 37 P(50), 38 P(60), 39 P(70), 40 P(80) 41 }; 42 C c(std::begin(a), std::end(a)); 43 std::pair<I, I> r = c.equal_range(30); 44 assert(std::distance(r.first, r.second) == 1); 45 assert(*r.first == 30); 46 r = c.equal_range(5); 47 assert(std::distance(r.first, r.second) == 0); 48 r = c.equal_range(50); 49 assert(std::distance(r.first, r.second) == 1); 50 assert(*r.first == 50); 51 } 52 #if __cplusplus >= 201103L 53 { 54 typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; 55 typedef C::iterator I; 56 typedef int P; 57 P a[] = 58 { 59 P(10), 60 P(20), 61 P(30), 62 P(40), 63 P(50), 64 P(50), 65 P(50), 66 P(60), 67 P(70), 68 P(80) 69 }; 70 C c(std::begin(a), std::end(a)); 71 std::pair<I, I> r = c.equal_range(30); 72 assert(std::distance(r.first, r.second) == 1); 73 assert(*r.first == 30); 74 r = c.equal_range(5); 75 assert(std::distance(r.first, r.second) == 0); 76 r = c.equal_range(50); 77 assert(std::distance(r.first, r.second) == 1); 78 assert(*r.first == 50); 79 } 80 #endif 81 } 82