Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2020 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
| 18 | |
Dominik Laskowski | 5444fc8 | 2020-11-24 13:41:10 -0800 | [diff] [blame] | 19 | #include <ftl/initializer_list.h> |
| 20 | #include <ftl/small_vector.h> |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 21 | |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 22 | #include <algorithm> |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 23 | #include <functional> |
| 24 | #include <optional> |
| 25 | #include <type_traits> |
| 26 | #include <utility> |
| 27 | |
| 28 | namespace android::ftl { |
| 29 | |
| 30 | // Associative container with unique, unordered keys. Unlike std::unordered_map, key-value pairs are |
| 31 | // stored in contiguous storage for cache efficiency. The map is allocated statically until its size |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 32 | // exceeds N, at which point mappings are relocated to dynamic memory. The try_emplace operation has |
| 33 | // a non-standard analogue try_replace that destructively emplaces. The API also defines an in-place |
| 34 | // counterpart to insert_or_assign: emplace_or_replace. Lookup is done not via a subscript operator, |
| 35 | // but immutable getters that can optionally transform the value. |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 36 | // |
| 37 | // SmallMap<K, V, 0> unconditionally allocates on the heap. |
| 38 | // |
| 39 | // Example usage: |
| 40 | // |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 41 | // ftl::SmallMap<int, std::string, 3> map; |
| 42 | // assert(map.empty()); |
| 43 | // assert(!map.dynamic()); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 44 | // |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 45 | // map = ftl::init::map<int, std::string>(123, "abc")(-1)(42, 3u, '?'); |
| 46 | // assert(map.size() == 3u); |
| 47 | // assert(!map.dynamic()); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 48 | // |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 49 | // assert(map.contains(123)); |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 50 | // assert(map.get(42, [](const std::string& s) { return s.size(); }) == 3u); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 51 | // |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 52 | // const auto opt = map.get(-1); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 53 | // assert(opt); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 54 | // |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 55 | // std::string& ref = *opt; |
| 56 | // assert(ref.empty()); |
| 57 | // ref = "xyz"; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 58 | // |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 59 | // map.emplace_or_replace(0, "vanilla", 2u, 3u); |
| 60 | // assert(map.dynamic()); |
| 61 | // |
| 62 | // assert(map == SmallMap(ftl::init::map(-1, "xyz")(0, "nil")(42, "???")(123, "abc"))); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 63 | // |
Dominik Laskowski | 5444fc8 | 2020-11-24 13:41:10 -0800 | [diff] [blame] | 64 | template <typename K, typename V, std::size_t N> |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 65 | class SmallMap final { |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 66 | using Map = SmallVector<std::pair<const K, V>, N>; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 67 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 68 | public: |
| 69 | using key_type = K; |
| 70 | using mapped_type = V; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 71 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 72 | using value_type = typename Map::value_type; |
| 73 | using size_type = typename Map::size_type; |
| 74 | using difference_type = typename Map::difference_type; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 75 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 76 | using reference = typename Map::reference; |
| 77 | using iterator = typename Map::iterator; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 78 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 79 | using const_reference = typename Map::const_reference; |
| 80 | using const_iterator = typename Map::const_iterator; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 81 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 82 | // Creates an empty map. |
| 83 | SmallMap() = default; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 84 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 85 | // Constructs at most N key-value pairs in place by forwarding per-pair constructor arguments. |
| 86 | // The template arguments K, V, and N are inferred using the deduction guide defined below. |
| 87 | // The syntax for listing pairs is as follows: |
| 88 | // |
| 89 | // ftl::SmallMap map = ftl::init::map<int, std::string>(123, "abc")(-1)(42, 3u, '?'); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 90 | // static_assert(std::is_same_v<decltype(map), ftl::SmallMap<int, std::string, 3>>); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 91 | // |
| 92 | // The types of the key and value are deduced if the first pair contains exactly two arguments: |
| 93 | // |
| 94 | // ftl::SmallMap map = ftl::init::map(0, 'a')(1, 'b')(2, 'c'); |
| 95 | // static_assert(std::is_same_v<decltype(map), ftl::SmallMap<int, char, 3>>); |
| 96 | // |
| 97 | template <typename U, std::size_t... Sizes, typename... Types> |
| 98 | SmallMap(InitializerList<U, std::index_sequence<Sizes...>, Types...>&& list) |
| 99 | : map_(std::move(list)) { |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 100 | deduplicate(); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 101 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 102 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 103 | size_type max_size() const { return map_.max_size(); } |
| 104 | size_type size() const { return map_.size(); } |
| 105 | bool empty() const { return map_.empty(); } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 106 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 107 | // Returns whether the map is backed by static or dynamic storage. |
| 108 | bool dynamic() const { return map_.dynamic(); } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 109 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 110 | iterator begin() { return map_.begin(); } |
| 111 | const_iterator begin() const { return cbegin(); } |
| 112 | const_iterator cbegin() const { return map_.cbegin(); } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 113 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 114 | iterator end() { return map_.end(); } |
| 115 | const_iterator end() const { return cend(); } |
| 116 | const_iterator cend() const { return map_.cend(); } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 117 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 118 | // Returns whether a mapping exists for the given key. |
| 119 | bool contains(const key_type& key) const { |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 120 | return get(key, [](const mapped_type&) {}); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 121 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 122 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 123 | // Returns a reference to the value for the given key, or std::nullopt if the key was not found. |
| 124 | // |
| 125 | // ftl::SmallMap map = ftl::init::map('a', 'A')('b', 'B')('c', 'C'); |
| 126 | // |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 127 | // const auto opt = map.get('c'); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 128 | // assert(opt == 'C'); |
| 129 | // |
| 130 | // char d = 'd'; |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 131 | // const auto ref = map.get('d').value_or(std::ref(d)); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 132 | // ref.get() = 'D'; |
| 133 | // assert(d == 'D'); |
| 134 | // |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 135 | auto get(const key_type& key) const -> std::optional<std::reference_wrapper<const mapped_type>> { |
| 136 | return get(key, [](const mapped_type& v) { return std::cref(v); }); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 137 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 138 | |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 139 | auto get(const key_type& key) -> std::optional<std::reference_wrapper<mapped_type>> { |
| 140 | return get(key, [](mapped_type& v) { return std::ref(v); }); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 141 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 142 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 143 | // Returns the result R of a unary operation F on (a constant or mutable reference to) the value |
| 144 | // for the given key, or std::nullopt if the key was not found. If F has a return type of void, |
| 145 | // then the Boolean result indicates whether the key was found. |
| 146 | // |
| 147 | // ftl::SmallMap map = ftl::init::map('a', 'x')('b', 'y')('c', 'z'); |
| 148 | // |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 149 | // assert(map.get('c', [](char c) { return std::toupper(c); }) == 'Z'); |
| 150 | // assert(map.get('c', [](char& c) { c = std::toupper(c); })); |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 151 | // |
| 152 | template <typename F, typename R = std::invoke_result_t<F, const mapped_type&>> |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 153 | auto get(const key_type& key, F f) const |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 154 | -> std::conditional_t<std::is_void_v<R>, bool, std::optional<R>> { |
| 155 | for (auto& [k, v] : *this) { |
| 156 | if (k == key) { |
| 157 | if constexpr (std::is_void_v<R>) { |
| 158 | f(v); |
| 159 | return true; |
| 160 | } else { |
| 161 | return f(v); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 162 | } |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 163 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 164 | } |
| 165 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 166 | return {}; |
| 167 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 168 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 169 | template <typename F> |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 170 | auto get(const key_type& key, F f) { |
| 171 | return std::as_const(*this).get( |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 172 | key, [&f](const mapped_type& v) { return f(const_cast<mapped_type&>(v)); }); |
| 173 | } |
| 174 | |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 175 | // Returns an iterator to an existing mapping for the given key, or the end() iterator otherwise. |
| 176 | const_iterator find(const key_type& key) const { return const_cast<SmallMap&>(*this).find(key); } |
| 177 | iterator find(const key_type& key) { return find(key, begin()); } |
| 178 | |
| 179 | // Inserts a mapping unless it exists. Returns an iterator to the inserted or existing mapping, |
| 180 | // and whether the mapping was inserted. |
| 181 | // |
| 182 | // On emplace, if the map reaches its static or dynamic capacity, then all iterators are |
| 183 | // invalidated. Otherwise, only the end() iterator is invalidated. |
| 184 | // |
| 185 | template <typename... Args> |
| 186 | std::pair<iterator, bool> try_emplace(const key_type& key, Args&&... args) { |
| 187 | if (const auto it = find(key); it != end()) { |
| 188 | return {it, false}; |
| 189 | } |
| 190 | |
| 191 | auto& ref = map_.emplace_back(std::piecewise_construct, std::forward_as_tuple(key), |
| 192 | std::forward_as_tuple(std::forward<Args>(args)...)); |
| 193 | return {&ref, true}; |
| 194 | } |
| 195 | |
| 196 | // Replaces a mapping if it exists, and returns an iterator to it. Returns the end() iterator |
| 197 | // otherwise. |
| 198 | // |
| 199 | // The value is replaced via move constructor, so type V does not need to define copy/move |
| 200 | // assignment, e.g. its data members may be const. |
| 201 | // |
| 202 | // The arguments may directly or indirectly refer to the mapping being replaced. |
| 203 | // |
| 204 | // Iterators to the replaced mapping point to its replacement, and others remain valid. |
| 205 | // |
| 206 | template <typename... Args> |
| 207 | iterator try_replace(const key_type& key, Args&&... args) { |
| 208 | const auto it = find(key); |
| 209 | if (it == end()) return it; |
| 210 | map_.replace(it, std::piecewise_construct, std::forward_as_tuple(key), |
| 211 | std::forward_as_tuple(std::forward<Args>(args)...)); |
| 212 | return it; |
| 213 | } |
| 214 | |
| 215 | // In-place counterpart of std::unordered_map's insert_or_assign. Returns true on emplace, or |
| 216 | // false on replace. |
| 217 | // |
| 218 | // The value is emplaced and replaced via move constructor, so type V does not need to define |
| 219 | // copy/move assignment, e.g. its data members may be const. |
| 220 | // |
| 221 | // On emplace, if the map reaches its static or dynamic capacity, then all iterators are |
| 222 | // invalidated. Otherwise, only the end() iterator is invalidated. On replace, iterators |
| 223 | // to the replaced mapping point to its replacement, and others remain valid. |
| 224 | // |
| 225 | template <typename... Args> |
| 226 | std::pair<iterator, bool> emplace_or_replace(const key_type& key, Args&&... args) { |
| 227 | const auto [it, ok] = try_emplace(key, std::forward<Args>(args)...); |
| 228 | if (ok) return {it, ok}; |
| 229 | map_.replace(it, std::piecewise_construct, std::forward_as_tuple(key), |
| 230 | std::forward_as_tuple(std::forward<Args>(args)...)); |
| 231 | return {it, ok}; |
| 232 | } |
| 233 | |
| 234 | // Removes a mapping if it exists, and returns whether it did. |
| 235 | // |
| 236 | // The last() and end() iterators, as well as those to the erased mapping, are invalidated. |
| 237 | // |
| 238 | bool erase(const key_type& key) { return erase(key, begin()); } |
| 239 | |
Dominik Laskowski | 44828ce | 2021-09-13 11:00:22 -0700 | [diff] [blame^] | 240 | // Removes all mappings. |
| 241 | // |
| 242 | // All iterators are invalidated. |
| 243 | // |
| 244 | void clear() { map_.clear(); } |
| 245 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 246 | private: |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 247 | iterator find(const key_type& key, iterator first) { |
| 248 | return std::find_if(first, end(), [&key](const auto& pair) { return pair.first == key; }); |
| 249 | } |
| 250 | |
| 251 | bool erase(const key_type& key, iterator first) { |
| 252 | const auto it = find(key, first); |
| 253 | if (it == end()) return false; |
| 254 | map_.unstable_erase(it); |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | void deduplicate() { |
| 259 | for (auto it = begin(); it != end();) { |
| 260 | if (const auto key = it->first; ++it != end()) { |
| 261 | while (erase(key, it)); |
| 262 | } |
| 263 | } |
| 264 | } |
| 265 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 266 | Map map_; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 267 | }; |
| 268 | |
| 269 | // Deduction guide for in-place constructor. |
Dominik Laskowski | 5444fc8 | 2020-11-24 13:41:10 -0800 | [diff] [blame] | 270 | template <typename K, typename V, std::size_t... Sizes, typename... Types> |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 271 | SmallMap(InitializerList<KeyValue<K, V>, std::index_sequence<Sizes...>, Types...>&&) |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 272 | -> SmallMap<K, V, sizeof...(Sizes)>; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 273 | |
| 274 | // Returns whether the key-value pairs of two maps are equal. |
Dominik Laskowski | 5444fc8 | 2020-11-24 13:41:10 -0800 | [diff] [blame] | 275 | template <typename K, typename V, std::size_t N, typename Q, typename W, std::size_t M> |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 276 | bool operator==(const SmallMap<K, V, N>& lhs, const SmallMap<Q, W, M>& rhs) { |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 277 | if (lhs.size() != rhs.size()) return false; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 278 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 279 | for (const auto& [k, v] : lhs) { |
| 280 | const auto& lv = v; |
Dominik Laskowski | dda9bba | 2021-02-03 18:56:00 -0800 | [diff] [blame] | 281 | if (!rhs.get(k, [&lv](const auto& rv) { return lv == rv; }).value_or(false)) { |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 282 | return false; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 283 | } |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 284 | } |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 285 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 286 | return true; |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 287 | } |
| 288 | |
| 289 | // TODO: Remove in C++20. |
Dominik Laskowski | 5444fc8 | 2020-11-24 13:41:10 -0800 | [diff] [blame] | 290 | template <typename K, typename V, std::size_t N, typename Q, typename W, std::size_t M> |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 291 | inline bool operator!=(const SmallMap<K, V, N>& lhs, const SmallMap<Q, W, M>& rhs) { |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 292 | return !(lhs == rhs); |
Dominik Laskowski | c4b9146 | 2020-11-02 13:37:25 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Dominik Laskowski | e21dbed | 2020-12-04 20:51:43 -0800 | [diff] [blame] | 295 | } // namespace android::ftl |