15#ifndef WPIUTIL_WPI_SMALLPTRSET_H
16#define WPIUTIL_WPI_SMALLPTRSET_H
27#include <initializer_list>
79 assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
80 "Initial size must be a power of two!");
93 [[nodiscard]]
bool empty()
const {
return size() == 0; }
103 return shrink_and_clear();
126 size_type NewSize = NumEntries + (NumEntries / 3);
129 NewSize = (std::max)(128u, NewSize);
139 return reinterpret_cast<void*
>(-1);
149 std::pair<const void *const *, bool>
insert_imp(
const void *Ptr) {
154 const void *Value = *APtr;
156 return std::make_pair(APtr,
false);
167 return insert_imp_big(Ptr);
187 auto *Bucket = doFind(Ptr);
202 const void *
const *
find_imp(
const void * Ptr)
const {
205 for (
const void *
const *APtr =
CurArray, *
const *E =
214 if (
auto *Bucket = doFind(Ptr))
224 for (; APtr != E; ++APtr)
230 return doFind(Ptr) !=
nullptr;
236 std::pair<const void *const *, bool> insert_imp_big(
const void *Ptr);
238 const void *
const *doFind(
const void *Ptr)
const;
239 const void *
const *FindBucketFor(
const void *Ptr)
const;
240 void shrink_and_clear();
243 void Grow(
unsigned NewSize);
248 void swap(
const void **SmallStorage,
const void **RHSSmallStorage,
252 void moveFrom(
const void **SmallStorage,
unsigned SmallSize,
257 void moveHelper(
const void **SmallStorage,
unsigned SmallSize,
309template <
typename PtrTy>
332 return PtrTraits::getFromVoidPointer(
const_cast<void *
>(
Bucket[-1]));
335 return PtrTraits::getFromVoidPointer(
const_cast<void*
>(*
Bucket));
362template <
typename PtrType>
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);
402 return erase_imp(PtrTraits::getAsVoidPointer(Ptr));
417 template <
typename UnaryPredicate>
419 bool Removed =
false;
423 PtrType Ptr = PtrTraits::getFromVoidPointer(
const_cast<void *
>(*APtr));
437 const void *Value = *APtr;
440 PtrType Ptr = PtrTraits::getFromVoidPointer(
const_cast<void *
>(Value));
453 return contains_imp(ConstPtrTraits::getAsVoidPointer(Ptr));
456 return makeIterator(
find_imp(ConstPtrTraits::getAsVoidPointer(Ptr)));
459 return contains_imp(ConstPtrTraits::getAsVoidPointer(Ptr));
462 template <
typename IterT>
468 void insert(std::initializer_list<PtrType> IL) {
469 insert(IL.begin(), IL.end());
481 iterator makeIterator(
const void *
const *P)
const {
492template <
typename PtrType>
498 for (
const auto *KV : LHS)
508template <
typename PtrType>
511 return !(LHS == RHS);
518template<
class PtrType,
unsigned SmallSize>
523 static_assert(SmallSize <= 32,
"SmallSize should be small");
529 static constexpr size_t RoundUpToPowerOfTwo(
size_t X) {
531 size_t CMax = C << (std::numeric_limits<size_t>::digits - 1);
532 while (C < X && C < CMax)
538 static constexpr size_t SmallSizePowTwo = RoundUpToPowerOfTwo(SmallSize);
540 const void *SmallStorage[SmallSizePowTwo];
546 : BaseT(SmallStorage, SmallSizePowTwo, that.SmallStorage,
549 template<
typename It>
555 : BaseT(SmallStorage, SmallSizePowTwo) {
556 this->
insert(IL.begin(), IL.end());
569 this->
moveFrom(SmallStorage, SmallSizePowTwo, RHS.SmallStorage,
577 this->
insert(IL.begin(), IL.end());
592 template<
class T,
unsigned N>
This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes.
#define LLVM_DEBUGEPOCHBASE_HANDLEBASE_EMPTYBASE
Definition EpochTracker.hpp:84
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
Definition EpochTracker.hpp:91
bool isHandleInSync() const
Definition EpochTracker.hpp:95
Definition EpochTracker.hpp:87
void incrementEpoch()
Definition EpochTracker.hpp:89
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition SmallPtrSet.hpp:519
void swap(SmallPtrSet< PtrType, SmallSize > &RHS)
swap - Swaps the elements of two sets.
Definition SmallPtrSet.hpp:582
SmallPtrSet(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.hpp:554
SmallPtrSet< PtrType, SmallSize > & operator=(const SmallPtrSet< PtrType, SmallSize > &RHS)
Definition SmallPtrSet.hpp:560
SmallPtrSet(const SmallPtrSet &that)
Definition SmallPtrSet.hpp:544
SmallPtrSet< PtrType, SmallSize > & operator=(SmallPtrSet< PtrType, SmallSize > &&RHS)
Definition SmallPtrSet.hpp:567
SmallPtrSet(It I, It E)
Definition SmallPtrSet.hpp:550
SmallPtrSet< PtrType, SmallSize > & operator=(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.hpp:575
SmallPtrSet(SmallPtrSet &&that)
Definition SmallPtrSet.hpp:545
SmallPtrSet()
Definition SmallPtrSet.hpp:543
unsigned CurArraySize
CurArraySize - The allocated size of CurArray, always a power of two.
Definition SmallPtrSet.hpp:59
void copyFrom(const void **SmallStorage, const SmallPtrSetImplBase &RHS)
static void * getEmptyMarker()
Definition SmallPtrSet.hpp:136
~SmallPtrSetImplBase()
Definition SmallPtrSet.hpp:83
bool IsSmall
Whether the set is in small representation.
Definition SmallPtrSet.hpp:68
unsigned NumTombstones
Number of tombstones in CurArray.
Definition SmallPtrSet.hpp:66
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&that)
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
const void ** EndPointer() const
Definition SmallPtrSet.hpp:142
const void ** CurArray
The current set of buckets, in either small or big representation.
Definition SmallPtrSet.hpp:57
friend class SmallPtrSetIteratorImpl
Definition SmallPtrSet.hpp:53
unsigned NumNonEmpty
Number of elements in CurArray that contain a value or are a tombstone.
Definition SmallPtrSet.hpp:64
bool isSmall() const
Definition SmallPtrSet.hpp:233
const void *const * find_imp(const void *Ptr) const
Returns the raw pointer needed to construct an iterator.
Definition SmallPtrSet.hpp:202
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize)
Definition SmallPtrSet.hpp:76
static void * getTombstoneMarker()
Definition SmallPtrSet.hpp:134
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.hpp:149
unsigned size_type
Definition SmallPtrSet.hpp:89
size_type size() const
Definition SmallPtrSet.hpp: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.hpp:174
SmallPtrSetImplBase & operator=(const SmallPtrSetImplBase &)=delete
void clear()
Definition SmallPtrSet.hpp:97
bool contains_imp(const void *Ptr) const
Definition SmallPtrSet.hpp:219
size_type capacity() const
Definition SmallPtrSet.hpp:95
void swap(const void **SmallStorage, const void **RHSSmallStorage, SmallPtrSetImplBase &RHS)
swap - Swaps the elements of two sets.
void reserve(size_type NumEntries)
Definition SmallPtrSet.hpp:112
void moveFrom(const void **SmallStorage, unsigned SmallSize, const void **RHSSmallStorage, SmallPtrSetImplBase &&RHS)
bool empty() const
Definition SmallPtrSet.hpp:93
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition SmallPtrSet.hpp:363
bool contains(ConstPtrType Ptr) const
Definition SmallPtrSet.hpp:458
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that)
iterator find(ConstPtrType Ptr) const
Definition SmallPtrSet.hpp:455
SmallPtrSetImpl(const SmallPtrSetImpl &)=delete
bool remove_if(UnaryPredicate P)
Remove elements that match the given predicate.
Definition SmallPtrSet.hpp:418
void insert(std::initializer_list< PtrType > IL)
Definition SmallPtrSet.hpp:468
iterator insert(iterator, PtrType Ptr)
Insert the given pointer with an iterator hint that is ignored.
Definition SmallPtrSet.hpp:392
void insert(IterT I, IterT E)
Definition SmallPtrSet.hpp:463
iterator begin() const
Definition SmallPtrSet.hpp:472
PtrType value_type
Definition SmallPtrSet.hpp:376
bool erase(PtrType Ptr)
Remove pointer from the set.
Definition SmallPtrSet.hpp:401
SmallPtrSetIterator< PtrType > iterator
Definition SmallPtrSet.hpp:373
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.hpp:384
iterator end() const
Definition SmallPtrSet.hpp:477
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition SmallPtrSet.hpp:452
ConstPtrType key_type
Definition SmallPtrSet.hpp:375
SmallPtrSetIterator< PtrType > const_iterator
Definition SmallPtrSet.hpp:374
SmallPtrSetIterator - This implements a const_iterator for SmallPtrSet.
Definition SmallPtrSet.hpp:312
PtrTy value_type
Definition SmallPtrSet.hpp:316
const PtrTy operator*() const
Definition SmallPtrSet.hpp:328
std::forward_iterator_tag iterator_category
Definition SmallPtrSet.hpp:320
std::ptrdiff_t difference_type
Definition SmallPtrSet.hpp:319
SmallPtrSetIterator operator++(int)
Definition SmallPtrSet.hpp:350
SmallPtrSetIterator(const void *const *BP, const void *const *E, const DebugEpochBase &Epoch)
Definition SmallPtrSet.hpp:322
PtrTy pointer
Definition SmallPtrSet.hpp:318
PtrTy reference
Definition SmallPtrSet.hpp:317
SmallPtrSetIterator & operator++()
Definition SmallPtrSet.hpp:338
const void *const * End
Definition SmallPtrSet.hpp:268
bool operator!=(const SmallPtrSetIteratorImpl &RHS) const
Definition SmallPtrSet.hpp:283
void AdvanceIfNotValid()
AdvanceIfNotValid - If the current bucket isn't valid, advance to a bucket that is.
Definition SmallPtrSet.hpp:291
void RetreatIfNotValid()
Definition SmallPtrSet.hpp:298
const void *const * Bucket
Definition SmallPtrSet.hpp:267
bool operator==(const SmallPtrSetIteratorImpl &RHS) const
Definition SmallPtrSet.hpp:280
SmallPtrSetIteratorImpl(const void *const *BP, const void *const *E)
Definition SmallPtrSet.hpp:271
Definition StringMap.hpp:773
void swap(wpi::util::StringMap< T > &lhs, wpi::util::StringMap< T > &rhs)
Definition StringMap.hpp:775
Definition raw_os_ostream.hpp:19
constexpr bool operator!=(const unexpected< E > &lhs, const unexpected< E > &rhs)
Definition expected:180
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.hpp:327
bool shouldReverseIterate()
Definition ReverseIteration.hpp:9
constexpr bool operator==(const unexpected< E > &lhs, const unexpected< E > &rhs)
Definition expected:176
A traits type that is used to handle pointer types and things that are just wrappers for pointers as ...
Definition PointerLikeTypeTraits.hpp:25
const T type
Definition type_traits.hpp:55