WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
SmallPtrSet.h
Go to the documentation of this file.
1//===- llvm/ADT/SmallPtrSet.h - 'Normally small' pointer set ----*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines the SmallPtrSet class. See the doxygen comment for
11/// SmallPtrSetImplBase for more details on the algorithm used.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef WPIUTIL_WPI_SMALLPTRSET_H
16#define WPIUTIL_WPI_SMALLPTRSET_H
17
18#include "wpi/EpochTracker.h"
19#include "wpi/Compiler.h"
21#include "wpi/type_traits.h"
22#include <cassert>
23#include <cstddef>
24#include <cstdlib>
25#include <cstring>
26#include <initializer_list>
27#include <iterator>
28#include <limits>
29#include <utility>
30
31namespace wpi {
32
33/// SmallPtrSetImplBase - This is the common code shared among all the
34/// SmallPtrSet<>'s, which is almost everything. SmallPtrSet has two modes, one
35/// for small and one for large sets.
36///
37/// Small sets use an array of pointers allocated in the SmallPtrSet object,
38/// which is treated as a simple array of pointers. When a pointer is added to
39/// the set, the array is scanned to see if the element already exists, if not
40/// the element is 'pushed back' onto the array. If we run out of space in the
41/// array, we grow into the 'large set' case. SmallSet should be used when the
42/// sets are often small. In this case, no memory allocation is used, and only
43/// light-weight and cache-efficient scanning is used.
44///
45/// Large sets use a classic exponentially-probed hash table. Empty buckets are
46/// represented with an illegal pointer value (-1) to allow null pointers to be
47/// inserted. Tombstones are represented with another illegal pointer value
48/// (-2), to allow deletion. The hash table is resized when the table is 3/4 or
49/// more. When this happens, the table is doubled in size.
50///
53
54protected:
55 /// SmallArray - Points to a fixed size set of buckets, used in 'small mode'.
56 const void **SmallArray;
57 /// CurArray - This is the current set of buckets. If equal to SmallArray,
58 /// then the set is in 'small mode'.
59 const void **CurArray;
60 /// CurArraySize - The allocated size of CurArray, always a power of two.
61 unsigned CurArraySize;
62
63 /// Number of elements in CurArray that contain a value or are a tombstone.
64 /// If small, all these elements are at the beginning of CurArray and the rest
65 /// is uninitialized.
66 unsigned NumNonEmpty;
67 /// Number of tombstones in CurArray.
68 unsigned NumTombstones;
69
70 // Helpers to copy and move construct a SmallPtrSet.
71 SmallPtrSetImplBase(const void **SmallStorage,
72 const SmallPtrSetImplBase &that);
73 SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize,
74 SmallPtrSetImplBase &&that);
75
76 explicit SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
77 : SmallArray(SmallStorage), CurArray(SmallStorage),
78 CurArraySize(SmallSize), NumNonEmpty(0), NumTombstones(0) {
79 assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
80 "Initial size must be a power of two!");
81 }
82
84 if (!isSmall())
86 }
87
88public:
89 using size_type = unsigned;
90
92
93 [[nodiscard]] bool empty() const { return size() == 0; }
95
96 void clear() {
98 // If the capacity of the array is huge, and the # elements used is small,
99 // shrink the array.
100 if (!isSmall()) {
101 if (size() * 4 < CurArraySize && CurArraySize > 32)
102 return shrink_and_clear();
103 // Fill the array with empty markers.
104 memset(CurArray, -1, CurArraySize * sizeof(void *));
105 }
106
107 NumNonEmpty = 0;
108 NumTombstones = 0;
109 }
110
111protected:
112 static void *getTombstoneMarker() { return reinterpret_cast<void*>(-2); }
113
114 static void *getEmptyMarker() {
115 // Note that -1 is chosen to make clear() efficiently implementable with
116 // memset and because it's not a valid pointer value.
117 return reinterpret_cast<void*>(-1);
118 }
119
120 const void **EndPointer() const {
122 }
123
124 /// insert_imp - This returns true if the pointer was new to the set, false if
125 /// it was already in the set. This is hidden from the client so that the
126 /// derived class can check that the right type of pointer is passed in.
127 std::pair<const void *const *, bool> insert_imp(const void *Ptr) {
128 if (isSmall()) {
129 // Check to see if it is already in the set.
130 for (const void **APtr = SmallArray, **E = SmallArray + NumNonEmpty;
131 APtr != E; ++APtr) {
132 const void *Value = *APtr;
133 if (Value == Ptr)
134 return std::make_pair(APtr, false);
135 }
136
137 // Nope, there isn't. If we stay small, just 'pushback' now.
139 SmallArray[NumNonEmpty++] = Ptr;
141 return std::make_pair(SmallArray + (NumNonEmpty - 1), true);
142 }
143 // Otherwise, hit the big set case, which will call grow.
144 }
145 return insert_imp_big(Ptr);
146 }
147
148 /// erase_imp - If the set contains the specified pointer, remove it and
149 /// return true, otherwise return false. This is hidden from the client so
150 /// that the derived class can check that the right type of pointer is passed
151 /// in.
152 bool erase_imp(const void * Ptr) {
153 if (isSmall()) {
154 for (const void **APtr = SmallArray, **E = SmallArray + NumNonEmpty;
155 APtr != E; ++APtr) {
156 if (*APtr == Ptr) {
157 *APtr = SmallArray[--NumNonEmpty];
159 return true;
160 }
161 }
162 return false;
163 }
164
165 auto *Bucket = FindBucketFor(Ptr);
166 if (*Bucket != Ptr)
167 return false;
168
169 *const_cast<const void **>(Bucket) = getTombstoneMarker();
171 // Treat this consistently from an API perspective, even if we don't
172 // actually invalidate iterators here.
174 return true;
175 }
176
177 /// Returns the raw pointer needed to construct an iterator. If element not
178 /// found, this will be EndPointer. Otherwise, it will be a pointer to the
179 /// slot which stores Ptr;
180 const void *const * find_imp(const void * Ptr) const {
181 if (isSmall()) {
182 // Linear search for the item.
183 for (const void *const *APtr = SmallArray,
184 *const *E = SmallArray + NumNonEmpty; APtr != E; ++APtr)
185 if (*APtr == Ptr)
186 return APtr;
187 return EndPointer();
188 }
189
190 // Big set case.
191 auto *Bucket = FindBucketFor(Ptr);
192 if (*Bucket == Ptr)
193 return Bucket;
194 return EndPointer();
195 }
196
197 bool isSmall() const { return CurArray == SmallArray; }
198
199private:
200 std::pair<const void *const *, bool> insert_imp_big(const void *Ptr);
201
202 const void * const *FindBucketFor(const void *Ptr) const;
203 void shrink_and_clear();
204
205 /// Grow - Allocate a larger backing store for the buckets and move it over.
206 void Grow(unsigned NewSize);
207
208protected:
209 /// swap - Swaps the elements of two sets.
210 /// Note: This method assumes that both sets have the same small size.
212
214 void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS);
215
216private:
217 /// Code shared by MoveFrom() and move constructor.
218 void MoveHelper(unsigned SmallSize, SmallPtrSetImplBase &&RHS);
219 /// Code shared by CopyFrom() and copy constructor.
220 void CopyHelper(const SmallPtrSetImplBase &RHS);
221};
222
223/// SmallPtrSetIteratorImpl - This is the common base class shared between all
224/// instances of SmallPtrSetIterator.
226protected:
227 const void *const *Bucket;
228 const void *const *End;
229
230public:
231 explicit SmallPtrSetIteratorImpl(const void *const *BP, const void*const *E)
232 : Bucket(BP), End(E) {
233 if (shouldReverseIterate()) {
235 return;
236 }
238 }
239
240 bool operator==(const SmallPtrSetIteratorImpl &RHS) const {
241 return Bucket == RHS.Bucket;
242 }
243 bool operator!=(const SmallPtrSetIteratorImpl &RHS) const {
244 return Bucket != RHS.Bucket;
245 }
246
247protected:
248 /// AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket
249 /// that is. This is guaranteed to stop because the end() bucket is marked
250 /// valid.
252 assert(Bucket <= End);
253 while (Bucket != End &&
256 ++Bucket;
257 }
259 assert(Bucket >= End);
260 while (Bucket != End &&
263 --Bucket;
264 }
265 }
266};
267
268/// SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
269template <typename PtrTy>
274
275public:
276 using value_type = PtrTy;
277 using reference = PtrTy;
278 using pointer = PtrTy;
279 using difference_type = std::ptrdiff_t;
280 using iterator_category = std::forward_iterator_tag;
281
282 explicit SmallPtrSetIterator(const void *const *BP, const void *const *E,
283 const DebugEpochBase &Epoch)
284 : SmallPtrSetIteratorImpl(BP, E), DebugEpochBase::HandleBase(&Epoch) {}
285
286 // Most methods are provided by the base class.
287
288 const PtrTy operator*() const {
289 assert(isHandleInSync() && "invalid iterator access!");
290 if (shouldReverseIterate()) {
291 assert(Bucket > End);
292 return PtrTraits::getFromVoidPointer(const_cast<void *>(Bucket[-1]));
293 }
294 assert(Bucket < End);
295 return PtrTraits::getFromVoidPointer(const_cast<void*>(*Bucket));
296 }
297
298 inline SmallPtrSetIterator& operator++() { // Preincrement
299 assert(isHandleInSync() && "invalid iterator access!");
300 if (shouldReverseIterate()) {
301 --Bucket;
302 RetreatIfNotValid();
303 return *this;
304 }
305 ++Bucket;
306 AdvanceIfNotValid();
307 return *this;
308 }
309
310 SmallPtrSetIterator operator++(int) { // Postincrement
311 SmallPtrSetIterator tmp = *this;
312 ++*this;
313 return tmp;
314 }
315};
316
317/// A templated base class for \c SmallPtrSet which provides the
318/// typesafe interface that is common across all small sizes.
319///
320/// This is particularly useful for passing around between interface boundaries
321/// to avoid encoding a particular small size in the interface boundary.
322template <typename PtrType>
324 using ConstPtrType = typename add_const_past_pointer<PtrType>::type;
327
328protected:
329 // Forward constructors to the base.
331
332public:
335 using key_type = ConstPtrType;
336 using value_type = PtrType;
337
339
340 /// Inserts Ptr if and only if there is no element in the container equal to
341 /// Ptr. The bool component of the returned pair is true if and only if the
342 /// insertion takes place, and the iterator component of the pair points to
343 /// the element equal to Ptr.
344 std::pair<iterator, bool> insert(PtrType Ptr) {
345 auto p = insert_imp(PtrTraits::getAsVoidPointer(Ptr));
346 return std::make_pair(makeIterator(p.first), p.second);
347 }
348
349 /// Insert the given pointer with an iterator hint that is ignored. This is
350 /// identical to calling insert(Ptr), but allows SmallPtrSet to be used by
351 /// std::insert_iterator and std::inserter().
352 iterator insert(iterator, PtrType Ptr) {
353 return insert(Ptr).first;
354 }
355
356 /// Remove pointer from the set.
357 ///
358 /// Returns whether the pointer was in the set. Invalidates iterators if
359 /// true is returned. To remove elements while iterating over the set, use
360 /// remove_if() instead.
361 bool erase(PtrType Ptr) {
362 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
363 }
364
365 /// Remove elements that match the given predicate.
366 ///
367 /// This method is a safe replacement for the following pattern, which is not
368 /// valid, because the erase() calls would invalidate the iterator:
369 ///
370 /// for (PtrType *Ptr : Set)
371 /// if (Pred(P))
372 /// Set.erase(P);
373 ///
374 /// Returns whether anything was removed. It is safe to read the set inside
375 /// the predicate function. However, the predicate must not modify the set
376 /// itself, only indicate a removal by returning true.
377 template <typename UnaryPredicate>
378 bool remove_if(UnaryPredicate P) {
379 bool Removed = false;
380 if (isSmall()) {
381 const void **APtr = SmallArray, **E = SmallArray + NumNonEmpty;
382 while (APtr != E) {
383 PtrType Ptr = PtrTraits::getFromVoidPointer(const_cast<void *>(*APtr));
384 if (P(Ptr)) {
385 *APtr = *--E;
386 --NumNonEmpty;
388 Removed = true;
389 } else {
390 ++APtr;
391 }
392 }
393 return Removed;
394 }
395
396 for (const void **APtr = CurArray, **E = EndPointer(); APtr != E; ++APtr) {
397 const void *Value = *APtr;
398 if (Value == getTombstoneMarker() || Value == getEmptyMarker())
399 continue;
400 PtrType Ptr = PtrTraits::getFromVoidPointer(const_cast<void *>(Value));
401 if (P(Ptr)) {
402 *APtr = getTombstoneMarker();
405 Removed = true;
406 }
407 }
408 return Removed;
409 }
410
411 /// count - Return 1 if the specified pointer is in the set, 0 otherwise.
412 size_type count(ConstPtrType Ptr) const {
413 return find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)) != EndPointer();
414 }
415 iterator find(ConstPtrType Ptr) const {
416 return makeIterator(find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)));
417 }
418 bool contains(ConstPtrType Ptr) const {
419 return find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)) != EndPointer();
420 }
421
422 template <typename IterT>
423 void insert(IterT I, IterT E) {
424 for (; I != E; ++I)
425 insert(*I);
426 }
427
428 void insert(std::initializer_list<PtrType> IL) {
429 insert(IL.begin(), IL.end());
430 }
431
432 iterator begin() const {
434 return makeIterator(EndPointer() - 1);
435 return makeIterator(CurArray);
436 }
437 iterator end() const { return makeIterator(EndPointer()); }
438
439private:
440 /// Create an iterator that dereferences to same place as the given pointer.
441 iterator makeIterator(const void *const *P) const {
443 return iterator(P == EndPointer() ? CurArray : P + 1, CurArray, *this);
444 return iterator(P, EndPointer(), *this);
445 }
446};
447
448/// Equality comparison for SmallPtrSet.
449///
450/// Iterates over elements of LHS confirming that each value from LHS is also in
451/// RHS, and that no additional values are in RHS.
452template <typename PtrType>
454 const SmallPtrSetImpl<PtrType> &RHS) {
455 if (LHS.size() != RHS.size())
456 return false;
457
458 for (const auto *KV : LHS)
459 if (!RHS.count(KV))
460 return false;
461
462 return true;
463}
464
465/// Inequality comparison for SmallPtrSet.
466///
467/// Equivalent to !(LHS == RHS).
468template <typename PtrType>
470 const SmallPtrSetImpl<PtrType> &RHS) {
471 return !(LHS == RHS);
472}
473
474/// SmallPtrSet - This class implements a set which is optimized for holding
475/// SmallSize or less elements. This internally rounds up SmallSize to the next
476/// power of two if it is not already a power of two. See the comments above
477/// SmallPtrSetImplBase for details of the algorithm.
478template<class PtrType, unsigned SmallSize>
479class SmallPtrSet : public SmallPtrSetImpl<PtrType> {
480 // In small mode SmallPtrSet uses linear search for the elements, so it is
481 // not a good idea to choose this value too high. You may consider using a
482 // DenseSet<> instead if you expect many elements in the set.
483 static_assert(SmallSize <= 32, "SmallSize should be small");
484
486
487 // A constexpr version of wpi::bit_ceil.
488 // TODO: Replace this with std::bit_ceil once C++20 is available.
489 static constexpr size_t RoundUpToPowerOfTwo(size_t X) {
490 size_t C = 1;
491 size_t CMax = C << (std::numeric_limits<size_t>::digits - 1);
492 while (C < X && C < CMax)
493 C <<= 1;
494 return C;
495 }
496
497 // Make sure that SmallSize is a power of two, round up if not.
498 static constexpr size_t SmallSizePowTwo = RoundUpToPowerOfTwo(SmallSize);
499 /// SmallStorage - Fixed size storage used in 'small mode'.
500 const void *SmallStorage[SmallSizePowTwo];
501
502public:
503 SmallPtrSet() : BaseT(SmallStorage, SmallSizePowTwo) {}
504 SmallPtrSet(const SmallPtrSet &that) : BaseT(SmallStorage, that) {}
506 : BaseT(SmallStorage, SmallSizePowTwo, std::move(that)) {}
507
508 template<typename It>
509 SmallPtrSet(It I, It E) : BaseT(SmallStorage, SmallSizePowTwo) {
510 this->insert(I, E);
511 }
512
513 SmallPtrSet(std::initializer_list<PtrType> IL)
514 : BaseT(SmallStorage, SmallSizePowTwo) {
515 this->insert(IL.begin(), IL.end());
516 }
517
520 if (&RHS != this)
521 this->CopyFrom(RHS);
522 return *this;
523 }
524
527 if (&RHS != this)
528 this->MoveFrom(SmallSizePowTwo, std::move(RHS));
529 return *this;
530 }
531
533 operator=(std::initializer_list<PtrType> IL) {
534 this->clear();
535 this->insert(IL.begin(), IL.end());
536 return *this;
537 }
538
539 /// swap - Swaps the elements of two sets.
543};
544
545} // end namespace wpi
546
547namespace std {
548
549 /// Implement std::swap in terms of SmallPtrSet swap.
550 template<class T, unsigned N>
552 LHS.swap(RHS);
553 }
554
555} // end namespace std
556
557#endif // WPIUTIL_WPI_SMALLPTRSET_H
This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes.
#define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE
Definition EpochTracker.h:25
and restrictions which apply to each piece of software is included later in this file and or inside of the individual applicable source files The disclaimer of warranty in the WPILib license above applies to all code in and nothing in any of the other licenses gives permission to use the names of FIRST nor the names of the WPILib contributors to endorse or promote products derived from this software The following pieces of software have additional or alternate and or and nanopb were all modified for use in Google Inc All rights reserved Redistribution and use in source and binary with or without are permitted provided that the following conditions are this list of conditions and the following disclaimer *Redistributions in binary form must reproduce the above copyright this list of conditions and the following disclaimer in the documentation and or other materials provided with the distribution *Neither the name of Google Inc nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS AND ANY EXPRESS OR IMPLIED BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY OR CONSEQUENTIAL WHETHER IN STRICT OR EVEN IF ADVISED OF THE POSSIBILITY OF SUCH January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable or merely the Work and Derivative Works thereof Contribution shall mean any work of including the original version of the Work and any modifications or additions to that Work or Derivative Works that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner For the purposes of this submitted means any form of or written communication sent to the Licensor or its including but not limited to communication on electronic mailing source code control and issue tracking systems that are managed or on behalf the Licensor for the purpose of discussing and improving the but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as Not a Contribution Contributor shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work Grant of Copyright License Subject to the terms and conditions of this each Contributor hereby grants to You a non no royalty free
Definition ThirdPartyNotices.txt:164
A base class for iterator classes ("handles") that wish to poll for iterator invalidating modificatio...
Definition EpochTracker.h:58
A base class for data structure classes wishing to make iterators ("handles") pointing into themselve...
Definition EpochTracker.h:36
void incrementEpoch()
Calling incrementEpoch invalidates all handles pointing into the calling instance.
Definition EpochTracker.h:44
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition SmallPtrSet.h:479
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
Definition SmallPtrSet.h:526
SmallPtrSet(SmallPtrSet &&that)
Definition SmallPtrSet.h:505
SmallPtrSet(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.h:513
SmallPtrSet(It I, It E)
Definition SmallPtrSet.h:509
SmallPtrSet< PtrType, SmallSize > & operator=(const SmallPtrSet< PtrType, SmallSize > &RHS)
Definition SmallPtrSet.h:519
SmallPtrSet< PtrType, SmallSize > & operator=(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.h:533
void swap(SmallPtrSet< PtrType, SmallSize > &RHS)
swap - Swaps the elements of two sets.
Definition SmallPtrSet.h:540
SmallPtrSet(const SmallPtrSet &that)
Definition SmallPtrSet.h:504
SmallPtrSet()
Definition SmallPtrSet.h:503
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s,...
Definition SmallPtrSet.h:51
std::pair< const void *const *, bool > insert_imp(const void *Ptr)
insert_imp - This returns true if the pointer was new to the set, false if it was already in the set.
Definition SmallPtrSet.h:127
unsigned NumNonEmpty
Number of elements in CurArray that contain a value or are a tombstone.
Definition SmallPtrSet.h:66
const void ** SmallArray
SmallArray - Points to a fixed size set of buckets, used in 'small mode'.
Definition SmallPtrSet.h:56
unsigned size_type
Definition SmallPtrSet.h:89
SmallPtrSetImplBase & operator=(const SmallPtrSetImplBase &)=delete
~SmallPtrSetImplBase()
Definition SmallPtrSet.h:83
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
bool isSmall() const
Definition SmallPtrSet.h:197
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
Definition SmallPtrSet.h:61
static void * getTombstoneMarker()
Definition SmallPtrSet.h:112
static void * getEmptyMarker()
Definition SmallPtrSet.h:114
const void *const * find_imp(const void *Ptr) const
Returns the raw pointer needed to construct an iterator.
Definition SmallPtrSet.h:180
void swap(SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
Definition SmallPtrSet.h:76
unsigned NumTombstones
Number of tombstones in CurArray.
Definition SmallPtrSet.h:68
void clear()
Definition SmallPtrSet.h:96
size_type size() const
Definition SmallPtrSet.h:94
bool erase_imp(const void *Ptr)
erase_imp - If the set contains the specified pointer, remove it and return true, otherwise return fa...
Definition SmallPtrSet.h:152
void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS)
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize, SmallPtrSetImplBase &&that)
const void ** EndPointer() const
Definition SmallPtrSet.h:120
void CopyFrom(const SmallPtrSetImplBase &RHS)
bool empty() const
Definition SmallPtrSet.h:93
const void ** CurArray
CurArray - This is the current set of buckets.
Definition SmallPtrSet.h:59
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition SmallPtrSet.h:323
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition SmallPtrSet.h:344
bool remove_if(UnaryPredicate P)
Remove elements that match the given predicate.
Definition SmallPtrSet.h:378
SmallPtrSetIterator< PtrType > iterator
Definition SmallPtrSet.h:333
bool erase(PtrType Ptr)
Remove pointer from the set.
Definition SmallPtrSet.h:361
iterator find(ConstPtrType Ptr) const
Definition SmallPtrSet.h:415
void insert(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.h:428
iterator end() const
Definition SmallPtrSet.h:437
ConstPtrType key_type
Definition SmallPtrSet.h:335
bool contains(ConstPtrType Ptr) const
Definition SmallPtrSet.h:418
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition SmallPtrSet.h:412
iterator begin() const
Definition SmallPtrSet.h:432
iterator insert(iterator, PtrType Ptr)
Insert the given pointer with an iterator hint that is ignored.
Definition SmallPtrSet.h:352
PtrType value_type
Definition SmallPtrSet.h:336
void insert(IterT I, IterT E)
Definition SmallPtrSet.h:423
SmallPtrSetImpl(const SmallPtrSetImpl &)=delete
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
Definition SmallPtrSet.h:272
PtrTy value_type
Definition SmallPtrSet.h:276
std::ptrdiff_t difference_type
Definition SmallPtrSet.h:279
SmallPtrSetIterator(const void *const *BP, const void *const *E, const DebugEpochBase &Epoch)
Definition SmallPtrSet.h:282
PtrTy pointer
Definition SmallPtrSet.h:278
std::forward_iterator_tag iterator_category
Definition SmallPtrSet.h:280
PtrTy reference
Definition SmallPtrSet.h:277
SmallPtrSetIterator & operator++()
Definition SmallPtrSet.h:298
const PtrTy operator*() const
Definition SmallPtrSet.h:288
SmallPtrSetIterator operator++(int)
Definition SmallPtrSet.h:310
SmallPtrSetIteratorImpl - This is the common base class shared between all instances of SmallPtrSetIt...
Definition SmallPtrSet.h:225
bool operator!=(const SmallPtrSetIteratorImpl &RHS) const
Definition SmallPtrSet.h:243
void AdvanceIfNotValid()
AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket that is.
Definition SmallPtrSet.h:251
const void *const * Bucket
Definition SmallPtrSet.h:227
const void *const * End
Definition SmallPtrSet.h:228
bool operator==(const SmallPtrSetIteratorImpl &RHS) const
Definition SmallPtrSet.h:240
SmallPtrSetIteratorImpl(const void *const *BP, const void *const *E)
Definition SmallPtrSet.h:231
void RetreatIfNotValid()
Definition SmallPtrSet.h:258
Implement std::hash so that hash_code can be used in STL containers.
Definition PointerIntPair.h:280
WPI_BASIC_JSON_TPL_DECLARATION void swap(wpi::WPI_BASIC_JSON_TPL &j1, wpi::WPI_BASIC_JSON_TPL &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name, cert-dcl58-cpp) is_nothrow_move_constructible< wpi::WPI_BASIC_JSON_TPL >::value &&//NOLINT(misc-redundant-expression, cppcoreguidelines-noexcept-swap, performance-noexcept-swap) is_nothrow_move_assignable< wpi::WPI_BASIC_JSON_TPL >::value)
exchanges the values of two JSON objects
Definition json.h:5258
Foonathan namespace.
Definition ntcore_cpp.h:26
bool operator==(const DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT > &LHS, const DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT > &RHS)
Equality comparison for DenseMap.
Definition DenseMap.h:729
bool operator!=(const DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT > &LHS, const DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT > &RHS)
Inequality comparison for DenseMap.
Definition DenseMap.h:749
bool shouldReverseIterate()
Definition ReverseIteration.h:9
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
Definition PointerLikeTypeTraits.h:25
const T type
Definition type_traits.h:55