WPILibC++ 2027.0.0-alpha-2
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/MathExtras.h"
21#include "wpi/type_traits.h"
22#include <algorithm>
23#include <cassert>
24#include <cstddef>
25#include <cstdlib>
26#include <cstring>
27#include <initializer_list>
28#include <iterator>
29#include <limits>
30#include <utility>
31
32namespace wpi {
33
34/// SmallPtrSetImplBase - This is the common code shared among all the
35/// SmallPtrSet<>'s, which is almost everything. SmallPtrSet has two modes, one
36/// for small and one for large sets.
37///
38/// Small sets use an array of pointers allocated in the SmallPtrSet object,
39/// which is treated as a simple array of pointers. When a pointer is added to
40/// the set, the array is scanned to see if the element already exists, if not
41/// the element is 'pushed back' onto the array. If we run out of space in the
42/// array, we grow into the 'large set' case. SmallSet should be used when the
43/// sets are often small. In this case, no memory allocation is used, and only
44/// light-weight and cache-efficient scanning is used.
45///
46/// Large sets use a classic exponentially-probed hash table. Empty buckets are
47/// represented with an illegal pointer value (-1) to allow null pointers to be
48/// inserted. Tombstones are represented with another illegal pointer value
49/// (-2), to allow deletion. The hash table is resized when the table is 3/4 or
50/// more. When this happens, the table is doubled in size.
51///
54
55protected:
56 /// The current set of buckets, in either small or big representation.
57 const void **CurArray;
58 /// CurArraySize - The allocated size of CurArray, always a power of two.
59 unsigned CurArraySize;
60
61 /// Number of elements in CurArray that contain a value or are a tombstone.
62 /// If small, all these elements are at the beginning of CurArray and the rest
63 /// is uninitialized.
64 unsigned NumNonEmpty;
65 /// Number of tombstones in CurArray.
66 unsigned NumTombstones;
67 /// Whether the set is in small representation.
68 bool IsSmall;
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 const void **RHSSmallStorage, SmallPtrSetImplBase &&that);
75
76 explicit SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
77 : CurArray(SmallStorage), CurArraySize(SmallSize), NumNonEmpty(0),
78 NumTombstones(0), IsSmall(true) {
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 size_type capacity() const { return CurArraySize; }
96
97 void clear() {
99 // If the capacity of the array is huge, and the # elements used is small,
100 // shrink the array.
101 if (!isSmall()) {
102 if (size() * 4 < CurArraySize && CurArraySize > 32)
103 return shrink_and_clear();
104 // Fill the array with empty markers.
105 memset(CurArray, -1, CurArraySize * sizeof(void *));
106 }
107
108 NumNonEmpty = 0;
109 NumTombstones = 0;
110 }
111
112 void reserve(size_type NumEntries) {
114 // Do nothing if we're given zero as a reservation size.
115 if (NumEntries == 0)
116 return;
117 // No need to expand if we're small and NumEntries will fit in the space.
118 if (isSmall() && NumEntries <= CurArraySize)
119 return;
120 // insert_imp_big will reallocate if stores is more than 75% full, on the
121 // /final/ insertion.
122 if (!isSmall() && ((NumEntries - 1) * 4) < (CurArraySize * 3))
123 return;
124 // We must Grow -- find the size where we'd be 75% full, then round up to
125 // the next power of two.
126 size_type NewSize = NumEntries + (NumEntries / 3);
127 NewSize = 1 << (Log2_32_Ceil(NewSize) + 1);
128 // Like insert_imp_big, always allocate at least 128 elements.
129 NewSize = (std::max)(128u, NewSize);
130 Grow(NewSize);
131 }
132
133protected:
134 static void *getTombstoneMarker() { return reinterpret_cast<void*>(-2); }
135
136 static void *getEmptyMarker() {
137 // Note that -1 is chosen to make clear() efficiently implementable with
138 // memset and because it's not a valid pointer value.
139 return reinterpret_cast<void*>(-1);
140 }
141
142 const void **EndPointer() const {
144 }
145
146 /// insert_imp - This returns true if the pointer was new to the set, false if
147 /// it was already in the set. This is hidden from the client so that the
148 /// derived class can check that the right type of pointer is passed in.
149 std::pair<const void *const *, bool> insert_imp(const void *Ptr) {
150 if (isSmall()) {
151 // Check to see if it is already in the set.
152 for (const void **APtr = CurArray, **E = CurArray + NumNonEmpty;
153 APtr != E; ++APtr) {
154 const void *Value = *APtr;
155 if (Value == Ptr)
156 return std::make_pair(APtr, false);
157 }
158
159 // Nope, there isn't. If we stay small, just 'pushback' now.
161 CurArray[NumNonEmpty++] = Ptr;
163 return std::make_pair(CurArray + (NumNonEmpty - 1), true);
164 }
165 // Otherwise, hit the big set case, which will call grow.
166 }
167 return insert_imp_big(Ptr);
168 }
169
170 /// erase_imp - If the set contains the specified pointer, remove it and
171 /// return true, otherwise return false. This is hidden from the client so
172 /// that the derived class can check that the right type of pointer is passed
173 /// in.
174 bool erase_imp(const void * Ptr) {
175 if (isSmall()) {
176 for (const void **APtr = CurArray, **E = CurArray + NumNonEmpty;
177 APtr != E; ++APtr) {
178 if (*APtr == Ptr) {
179 *APtr = CurArray[--NumNonEmpty];
181 return true;
182 }
183 }
184 return false;
185 }
186
187 auto *Bucket = doFind(Ptr);
188 if (!Bucket)
189 return false;
190
191 *const_cast<const void **>(Bucket) = getTombstoneMarker();
193 // Treat this consistently from an API perspective, even if we don't
194 // actually invalidate iterators here.
196 return true;
197 }
198
199 /// Returns the raw pointer needed to construct an iterator. If element not
200 /// found, this will be EndPointer. Otherwise, it will be a pointer to the
201 /// slot which stores Ptr;
202 const void *const * find_imp(const void * Ptr) const {
203 if (isSmall()) {
204 // Linear search for the item.
205 for (const void *const *APtr = CurArray, *const *E =
207 APtr != E; ++APtr)
208 if (*APtr == Ptr)
209 return APtr;
210 return EndPointer();
211 }
212
213 // Big set case.
214 if (auto *Bucket = doFind(Ptr))
215 return Bucket;
216 return EndPointer();
217 }
218
219 bool contains_imp(const void *Ptr) const {
220 if (isSmall()) {
221 // Linear search for the item.
222 const void *const *APtr = CurArray;
223 const void *const *E = CurArray + NumNonEmpty;
224 for (; APtr != E; ++APtr)
225 if (*APtr == Ptr)
226 return true;
227 return false;
228 }
229
230 return doFind(Ptr) != nullptr;
231 }
232
233 bool isSmall() const { return IsSmall; }
234
235private:
236 std::pair<const void *const *, bool> insert_imp_big(const void *Ptr);
237
238 const void *const *doFind(const void *Ptr) const;
239 const void * const *FindBucketFor(const void *Ptr) const;
240 void shrink_and_clear();
241
242 /// Grow - Allocate a larger backing store for the buckets and move it over.
243 void Grow(unsigned NewSize);
244
245protected:
246 /// swap - Swaps the elements of two sets.
247 /// Note: This method assumes that both sets have the same small size.
248 void swap(const void **SmallStorage, const void **RHSSmallStorage,
250
251 void copyFrom(const void **SmallStorage, const SmallPtrSetImplBase &RHS);
252 void moveFrom(const void **SmallStorage, unsigned SmallSize,
253 const void **RHSSmallStorage, SmallPtrSetImplBase &&RHS);
254
255private:
256 /// Code shared by moveFrom() and move constructor.
257 void moveHelper(const void **SmallStorage, unsigned SmallSize,
258 const void **RHSSmallStorage, SmallPtrSetImplBase &&RHS);
259 /// Code shared by copyFrom() and copy constructor.
260 void copyHelper(const SmallPtrSetImplBase &RHS);
261};
262
263/// SmallPtrSetIteratorImpl - This is the common base class shared between all
264/// instances of SmallPtrSetIterator.
266protected:
267 const void *const *Bucket;
268 const void *const *End;
269
270public:
271 explicit SmallPtrSetIteratorImpl(const void *const *BP, const void*const *E)
272 : Bucket(BP), End(E) {
273 if (shouldReverseIterate()) {
275 return;
276 }
278 }
279
280 bool operator==(const SmallPtrSetIteratorImpl &RHS) const {
281 return Bucket == RHS.Bucket;
282 }
283 bool operator!=(const SmallPtrSetIteratorImpl &RHS) const {
284 return Bucket != RHS.Bucket;
285 }
286
287protected:
288 /// AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket
289 /// that is. This is guaranteed to stop because the end() bucket is marked
290 /// valid.
292 assert(Bucket <= End);
293 while (Bucket != End &&
296 ++Bucket;
297 }
299 assert(Bucket >= End);
300 while (Bucket != End &&
303 --Bucket;
304 }
305 }
306};
307
308/// SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
309template <typename PtrTy>
314
315public:
316 using value_type = PtrTy;
317 using reference = PtrTy;
318 using pointer = PtrTy;
319 using difference_type = std::ptrdiff_t;
320 using iterator_category = std::forward_iterator_tag;
321
322 explicit SmallPtrSetIterator(const void *const *BP, const void *const *E,
323 const DebugEpochBase &Epoch)
324 : SmallPtrSetIteratorImpl(BP, E), DebugEpochBase::HandleBase(&Epoch) {}
325
326 // Most methods are provided by the base class.
327
328 const PtrTy operator*() const {
329 assert(isHandleInSync() && "invalid iterator access!");
330 if (shouldReverseIterate()) {
331 assert(Bucket > End);
332 return PtrTraits::getFromVoidPointer(const_cast<void *>(Bucket[-1]));
333 }
334 assert(Bucket < End);
335 return PtrTraits::getFromVoidPointer(const_cast<void*>(*Bucket));
336 }
337
338 inline SmallPtrSetIterator& operator++() { // Preincrement
339 assert(isHandleInSync() && "invalid iterator access!");
340 if (shouldReverseIterate()) {
341 --Bucket;
342 RetreatIfNotValid();
343 return *this;
344 }
345 ++Bucket;
346 AdvanceIfNotValid();
347 return *this;
348 }
349
350 SmallPtrSetIterator operator++(int) { // Postincrement
351 SmallPtrSetIterator tmp = *this;
352 ++*this;
353 return tmp;
354 }
355};
356
357/// A templated base class for \c SmallPtrSet which provides the
358/// typesafe interface that is common across all small sizes.
359///
360/// This is particularly useful for passing around between interface boundaries
361/// to avoid encoding a particular small size in the interface boundary.
362template <typename PtrType>
364 using ConstPtrType = typename add_const_past_pointer<PtrType>::type;
367
368protected:
369 // Forward constructors to the base.
371
372public:
375 using key_type = ConstPtrType;
376 using value_type = PtrType;
377
379
380 /// Inserts Ptr if and only if there is no element in the container equal to
381 /// Ptr. The bool component of the returned pair is true if and only if the
382 /// insertion takes place, and the iterator component of the pair points to
383 /// the element equal to Ptr.
384 std::pair<iterator, bool> insert(PtrType Ptr) {
385 auto p = insert_imp(PtrTraits::getAsVoidPointer(Ptr));
386 return std::make_pair(makeIterator(p.first), p.second);
387 }
388
389 /// Insert the given pointer with an iterator hint that is ignored. This is
390 /// identical to calling insert(Ptr), but allows SmallPtrSet to be used by
391 /// std::insert_iterator and std::inserter().
392 iterator insert(iterator, PtrType Ptr) {
393 return insert(Ptr).first;
394 }
395
396 /// Remove pointer from the set.
397 ///
398 /// Returns whether the pointer was in the set. Invalidates iterators if
399 /// true is returned. To remove elements while iterating over the set, use
400 /// remove_if() instead.
401 bool erase(PtrType Ptr) {
402 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
403 }
404
405 /// Remove elements that match the given predicate.
406 ///
407 /// This method is a safe replacement for the following pattern, which is not
408 /// valid, because the erase() calls would invalidate the iterator:
409 ///
410 /// for (PtrType *Ptr : Set)
411 /// if (Pred(P))
412 /// Set.erase(P);
413 ///
414 /// Returns whether anything was removed. It is safe to read the set inside
415 /// the predicate function. However, the predicate must not modify the set
416 /// itself, only indicate a removal by returning true.
417 template <typename UnaryPredicate>
418 bool remove_if(UnaryPredicate P) {
419 bool Removed = false;
420 if (isSmall()) {
421 const void **APtr = CurArray, **E = CurArray + NumNonEmpty;
422 while (APtr != E) {
423 PtrType Ptr = PtrTraits::getFromVoidPointer(const_cast<void *>(*APtr));
424 if (P(Ptr)) {
425 *APtr = *--E;
426 --NumNonEmpty;
428 Removed = true;
429 } else {
430 ++APtr;
431 }
432 }
433 return Removed;
434 }
435
436 for (const void **APtr = CurArray, **E = EndPointer(); APtr != E; ++APtr) {
437 const void *Value = *APtr;
438 if (Value == getTombstoneMarker() || Value == getEmptyMarker())
439 continue;
440 PtrType Ptr = PtrTraits::getFromVoidPointer(const_cast<void *>(Value));
441 if (P(Ptr)) {
442 *APtr = getTombstoneMarker();
445 Removed = true;
446 }
447 }
448 return Removed;
449 }
450
451 /// count - Return 1 if the specified pointer is in the set, 0 otherwise.
452 size_type count(ConstPtrType Ptr) const {
453 return contains_imp(ConstPtrTraits::getAsVoidPointer(Ptr));
454 }
455 iterator find(ConstPtrType Ptr) const {
456 return makeIterator(find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)));
457 }
458 bool contains(ConstPtrType Ptr) const {
459 return contains_imp(ConstPtrTraits::getAsVoidPointer(Ptr));
460 }
461
462 template <typename IterT>
463 void insert(IterT I, IterT E) {
464 for (; I != E; ++I)
465 insert(*I);
466 }
467
468 void insert(std::initializer_list<PtrType> IL) {
469 insert(IL.begin(), IL.end());
470 }
471
472 iterator begin() const {
474 return makeIterator(EndPointer() - 1);
475 return makeIterator(CurArray);
476 }
477 iterator end() const { return makeIterator(EndPointer()); }
478
479private:
480 /// Create an iterator that dereferences to same place as the given pointer.
481 iterator makeIterator(const void *const *P) const {
483 return iterator(P == EndPointer() ? CurArray : P + 1, CurArray, *this);
484 return iterator(P, EndPointer(), *this);
485 }
486};
487
488/// Equality comparison for SmallPtrSet.
489///
490/// Iterates over elements of LHS confirming that each value from LHS is also in
491/// RHS, and that no additional values are in RHS.
492template <typename PtrType>
494 const SmallPtrSetImpl<PtrType> &RHS) {
495 if (LHS.size() != RHS.size())
496 return false;
497
498 for (const auto *KV : LHS)
499 if (!RHS.count(KV))
500 return false;
501
502 return true;
503}
504
505/// Inequality comparison for SmallPtrSet.
506///
507/// Equivalent to !(LHS == RHS).
508template <typename PtrType>
510 const SmallPtrSetImpl<PtrType> &RHS) {
511 return !(LHS == RHS);
512}
513
514/// SmallPtrSet - This class implements a set which is optimized for holding
515/// SmallSize or less elements. This internally rounds up SmallSize to the next
516/// power of two if it is not already a power of two. See the comments above
517/// SmallPtrSetImplBase for details of the algorithm.
518template<class PtrType, unsigned SmallSize>
519class SmallPtrSet : public SmallPtrSetImpl<PtrType> {
520 // In small mode SmallPtrSet uses linear search for the elements, so it is
521 // not a good idea to choose this value too high. You may consider using a
522 // DenseSet<> instead if you expect many elements in the set.
523 static_assert(SmallSize <= 32, "SmallSize should be small");
524
526
527 // A constexpr version of wpi::bit_ceil.
528 // TODO: Replace this with std::bit_ceil once C++20 is available.
529 static constexpr size_t RoundUpToPowerOfTwo(size_t X) {
530 size_t C = 1;
531 size_t CMax = C << (std::numeric_limits<size_t>::digits - 1);
532 while (C < X && C < CMax)
533 C <<= 1;
534 return C;
535 }
536
537 // Make sure that SmallSize is a power of two, round up if not.
538 static constexpr size_t SmallSizePowTwo = RoundUpToPowerOfTwo(SmallSize);
539 /// SmallStorage - Fixed size storage used in 'small mode'.
540 const void *SmallStorage[SmallSizePowTwo];
541
542public:
543 SmallPtrSet() : BaseT(SmallStorage, SmallSizePowTwo) {}
544 SmallPtrSet(const SmallPtrSet &that) : BaseT(SmallStorage, that) {}
546 : BaseT(SmallStorage, SmallSizePowTwo, that.SmallStorage,
547 std::move(that)) {}
548
549 template<typename It>
550 SmallPtrSet(It I, It E) : BaseT(SmallStorage, SmallSizePowTwo) {
551 this->insert(I, E);
552 }
553
554 SmallPtrSet(std::initializer_list<PtrType> IL)
555 : BaseT(SmallStorage, SmallSizePowTwo) {
556 this->insert(IL.begin(), IL.end());
557 }
558
561 if (&RHS != this)
562 this->copyFrom(SmallStorage, RHS);
563 return *this;
564 }
565
568 if (&RHS != this)
569 this->moveFrom(SmallStorage, SmallSizePowTwo, RHS.SmallStorage,
570 std::move(RHS));
571 return *this;
572 }
573
575 operator=(std::initializer_list<PtrType> IL) {
576 this->clear();
577 this->insert(IL.begin(), IL.end());
578 return *this;
579 }
580
581 /// swap - Swaps the elements of two sets.
583 SmallPtrSetImplBase::swap(SmallStorage, RHS.SmallStorage, RHS);
584 }
585};
586
587} // end namespace wpi
588
589namespace std {
590
591 /// Implement std::swap in terms of SmallPtrSet swap.
592 template<class T, unsigned N>
594 LHS.swap(RHS);
595 }
596
597} // end namespace std
598
599#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 glfw and nanopb were 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:163
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:519
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
Definition SmallPtrSet.h:567
SmallPtrSet(SmallPtrSet &&that)
Definition SmallPtrSet.h:545
SmallPtrSet(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.h:554
SmallPtrSet(It I, It E)
Definition SmallPtrSet.h:550
SmallPtrSet< PtrType, SmallSize > & operator=(const SmallPtrSet< PtrType, SmallSize > &RHS)
Definition SmallPtrSet.h:560
SmallPtrSet< PtrType, SmallSize > & operator=(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.h:575
void swap(SmallPtrSet< PtrType, SmallSize > &RHS)
swap - Swaps the elements of two sets.
Definition SmallPtrSet.h:582
SmallPtrSet(const SmallPtrSet &that)
Definition SmallPtrSet.h:544
SmallPtrSet()
Definition SmallPtrSet.h:543
SmallPtrSetImplBase - This is the common code shared among all the SmallPtrSet<>'s,...
Definition SmallPtrSet.h:52
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:149
bool IsSmall
Whether the set is in small representation.
Definition SmallPtrSet.h:68
unsigned NumNonEmpty
Number of elements in CurArray that contain a value or are a tombstone.
Definition SmallPtrSet.h:64
bool contains_imp(const void *Ptr) const
Definition SmallPtrSet.h:219
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:233
void moveFrom(const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&RHS)
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
Definition SmallPtrSet.h:59
void copyFrom(const void **SmallStorage, const SmallPtrSetImplBase &RHS)
static void * getTombstoneMarker()
Definition SmallPtrSet.h:134
static void * getEmptyMarker()
Definition SmallPtrSet.h:136
const void *const * find_imp(const void *Ptr) const
Returns the raw pointer needed to construct an iterator.
Definition SmallPtrSet.h:202
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&that)
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
Definition SmallPtrSet.h:76
unsigned NumTombstones
Number of tombstones in CurArray.
Definition SmallPtrSet.h:66
void reserve(size_type NumEntries)
Definition SmallPtrSet.h:112
void swap(const void **SmallStorage, const void **RHSSmallStorage, SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
void clear()
Definition SmallPtrSet.h:97
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:174
const void ** EndPointer() const
Definition SmallPtrSet.h:142
bool empty() const
Definition SmallPtrSet.h:93
const void ** CurArray
The current set of buckets, in either small or big representation.
Definition SmallPtrSet.h:57
size_type capacity() const
Definition SmallPtrSet.h:95
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition SmallPtrSet.h:363
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:384
bool remove_if(UnaryPredicate P)
Remove elements that match the given predicate.
Definition SmallPtrSet.h:418
SmallPtrSetIterator< PtrType > iterator
Definition SmallPtrSet.h:373
bool erase(PtrType Ptr)
Remove pointer from the set.
Definition SmallPtrSet.h:401
iterator find(ConstPtrType Ptr) const
Definition SmallPtrSet.h:455
void insert(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.h:468
iterator end() const
Definition SmallPtrSet.h:477
ConstPtrType key_type
Definition SmallPtrSet.h:375
bool contains(ConstPtrType Ptr) const
Definition SmallPtrSet.h:458
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition SmallPtrSet.h:452
iterator begin() const
Definition SmallPtrSet.h:472
iterator insert(iterator, PtrType Ptr)
Insert the given pointer with an iterator hint that is ignored.
Definition SmallPtrSet.h:392
PtrType value_type
Definition SmallPtrSet.h:376
void insert(IterT I, IterT E)
Definition SmallPtrSet.h:463
SmallPtrSetImpl(const SmallPtrSetImpl &)=delete
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
Definition SmallPtrSet.h:312
PtrTy value_type
Definition SmallPtrSet.h:316
std::ptrdiff_t difference_type
Definition SmallPtrSet.h:319
SmallPtrSetIterator(const void *const *BP, const void *const *E, const DebugEpochBase &Epoch)
Definition SmallPtrSet.h:322
PtrTy pointer
Definition SmallPtrSet.h:318
std::forward_iterator_tag iterator_category
Definition SmallPtrSet.h:320
PtrTy reference
Definition SmallPtrSet.h:317
SmallPtrSetIterator & operator++()
Definition SmallPtrSet.h:338
const PtrTy operator*() const
Definition SmallPtrSet.h:328
SmallPtrSetIterator operator++(int)
Definition SmallPtrSet.h:350
SmallPtrSetIteratorImpl - This is the common base class shared between all instances of SmallPtrSetIt...
Definition SmallPtrSet.h:265
bool operator!=(const SmallPtrSetIteratorImpl &RHS) const
Definition SmallPtrSet.h:283
void AdvanceIfNotValid()
AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket that is.
Definition SmallPtrSet.h:291
const void *const * Bucket
Definition SmallPtrSet.h:267
const void *const * End
Definition SmallPtrSet.h:268
bool operator==(const SmallPtrSetIteratorImpl &RHS) const
Definition SmallPtrSet.h:280
SmallPtrSetIteratorImpl(const void *const *BP, const void *const *E)
Definition SmallPtrSet.h:271
void RetreatIfNotValid()
Definition SmallPtrSet.h:298
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
Definition ntcore_cpp.h:26
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition MathExtras.h:327
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:698
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:718
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