LEFT | RIGHT |
| 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. |
| 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ |
| 17 |
1 #pragma once | 18 #pragma once |
2 | 19 |
3 #include <cstddef> | 20 #include <cstddef> |
4 #include <cmath> | 21 #include <cmath> |
5 #include <initializer_list> | 22 #include <initializer_list> |
6 #include <memory> | 23 #include <memory> |
7 | 24 |
8 #include "String.h" | 25 #include "String.h" |
9 #include "debug.h" | 26 #include "debug.h" |
10 | 27 |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 return const_iterator(&mBuckets[0], &mBuckets[mBucketCount]); | 228 return const_iterator(&mBuckets[0], &mBuckets[mBucketCount]); |
212 } | 229 } |
213 | 230 |
214 const_iterator end() const | 231 const_iterator end() const |
215 { | 232 { |
216 return const_iterator(&mBuckets[mBucketCount], &mBuckets[mBucketCount]); | 233 return const_iterator(&mBuckets[mBucketCount], &mBuckets[mBucketCount]); |
217 } | 234 } |
218 | 235 |
219 size_type size() const | 236 size_type size() const |
220 { | 237 { |
221 return mBucketCount; | |
222 } | |
223 | |
224 size_type length() const | |
225 { | |
226 return mEntryCount; | 238 return mEntryCount; |
227 } | 239 } |
228 }; | 240 }; |
229 | 241 |
230 struct StringSetEntry | 242 struct StringSetEntry |
231 { | 243 { |
232 StringSetEntry() {} | 244 StringSetEntry() {} |
233 StringSetEntry(const String& key) | 245 StringSetEntry(const String& key) |
234 : first(key) | 246 : first(key) |
235 { | 247 { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 friend class StringMap_internal::StringMapEntryReference<T>; | 322 friend class StringMap_internal::StringMapEntryReference<T>; |
311 | 323 |
312 explicit StringMap(size_type expectedEntries = 0) | 324 explicit StringMap(size_type expectedEntries = 0) |
313 : super(expectedEntries) | 325 : super(expectedEntries) |
314 { | 326 { |
315 } | 327 } |
316 | 328 |
317 StringMap(std::initializer_list<entry_type> list) | 329 StringMap(std::initializer_list<entry_type> list) |
318 : super(list.size()) | 330 : super(list.size()) |
319 { | 331 { |
320 for (auto it = list.begin(); it != list.end(); ++it) | 332 for (const auto& item : list) |
321 super::insert(*it); | 333 super::insert(item); |
322 } | 334 } |
323 | 335 |
324 ~StringMap() | 336 ~StringMap() |
325 { | 337 { |
326 } | 338 } |
327 | 339 |
328 T& operator[](const String& key) | 340 T& operator[](const String& key) |
329 { | 341 { |
330 entry_type* entry = super::find_bucket(key); | 342 entry_type* entry = super::find_bucket(key); |
331 if (entry->first.is_invalid()) | 343 if (entry->first.is_invalid()) |
332 entry = super::assign(entry, key); | 344 entry = super::assign(entry, key); |
333 return entry->second; | 345 return entry->second; |
334 } | 346 } |
335 | 347 |
336 const_reference find(const String& key) const | 348 const_reference find(const String& key) const |
337 { | 349 { |
338 return super::find(key); | 350 return super::find(key); |
339 } | 351 } |
340 | 352 |
341 reference find(const String& key) | 353 reference find(const String& key) |
342 { | 354 { |
343 return reference(this, key, super::find_bucket(key)); | 355 return reference(this, key, super::find_bucket(key)); |
344 } | 356 } |
345 }; | 357 }; |
LEFT | RIGHT |