14#ifndef WPIUTIL_WPI_SMALLSET_H 
   15#define WPIUTIL_WPI_SMALLSET_H 
   33template <
typename T, 
unsigned N, 
typename C>
 
   36                                  std::forward_iterator_tag, T> {
 
   38  using SetIterTy = 
typename std::set<T, C>::const_iterator;
 
   76      VecIter = std::move(Other.VecIter);
 
   80      new (&
SetIter) SetIterTy(std::move(Other.SetIter));
 
 
   89    isSmall = Other.isSmall;
 
 
  103    isSmall = Other.isSmall;
 
  105      VecIter = std::move(Other.VecIter);
 
  107      new (&
SetIter) SetIterTy(std::move(Other.SetIter));
 
 
  112    if (isSmall != RHS.isSmall)
 
 
 
  134template <
typename T, 
unsigned N, 
typename C = std::less<T>>
 
  143  using SIterator = 
typename std::set<T, C>::const_iterator;
 
  149  static_assert(N <= 32, 
"N should be small");
 
  159  [[nodiscard]] 
bool empty()
 const { 
return Vector.
empty() && Set.empty(); }
 
  162    return isSmall() ? Vector.
size() : Set.size();
 
 
  169      return vfind(V) == Vector.
end() ? 0 : 1;
 
 
  179  std::pair<const_iterator, bool> 
insert(
const T &V) {
 
  181      auto [I, Inserted] = Set.insert(V);
 
  185    VIterator I = vfind(V);
 
  186    if (I != Vector.
end())    
 
  188    if (Vector.
size() < N) {
 
  194    while (!Vector.
empty()) {
 
  195      Set.insert(Vector.
back());
 
 
  201  template <
typename IterT>
 
  210    for (mutable_iterator I = Vector.
begin(), E = Vector.
end(); I != E; ++I)
 
 
  225      return {Vector.
begin()};
 
  226    return {Set.begin()};
 
 
  231      return {Vector.
end()};
 
 
  238      return vfind(V) != Vector.
end();
 
  239    return Set.find(V) != Set.end();
 
 
  243  bool isSmall()
 const { 
return Set.empty(); }
 
  245  VIterator vfind(
const T &V)
 const {
 
  246    for (VIterator I = Vector.
begin(), E = Vector.
end(); I != E; ++I)
 
 
  255template <
typename Po
inteeType, 
unsigned N>
 
  266template <
typename T, 
unsigned LN, 
unsigned RN, 
typename C>
 
  272  return std::all_of(LHS.
begin(), LHS.
end(), [&RHS](
const T &E) { return RHS.count(E); });
 
 
  278template <
typename T, 
unsigned LN, 
unsigned RN, 
typename C>
 
  280  return !(LHS == RHS);
 
 
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition SmallPtrSet.h:479
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition SmallSet.h:135
T value_type
Definition SmallSet.h:154
T key_type
Definition SmallSet.h:152
bool erase(const T &V)
Definition SmallSet.h:207
const_iterator end() const
Definition SmallSet.h:229
size_t size_type
Definition SmallSet.h:153
void insert(IterT I, IterT E)
Definition SmallSet.h:202
bool contains(const T &V) const
Check if the SmallSet contains the given element.
Definition SmallSet.h:236
bool empty() const
Definition SmallSet.h:159
size_type count(const T &V) const
count - Return 1 if the element is in the set, 0 otherwise.
Definition SmallSet.h:166
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Definition SmallSet.h:179
SmallSetIterator< T, N, C > const_iterator
Definition SmallSet.h:155
void clear()
Definition SmallSet.h:218
const_iterator begin() const
Definition SmallSet.h:223
size_type size() const
Definition SmallSet.h:161
SmallSetIterator - This class implements a const_iterator for SmallSet by delegating to the underlyin...
Definition SmallSet.h:36
SmallSetIterator(const SmallSetIterator &Other)
Definition SmallSet.h:65
SmallSetIterator(SetIterTy SetIter)
Definition SmallSet.h:52
bool operator==(const SmallSetIterator &RHS) const
Definition SmallSet.h:111
SetIterTy SetIter
Definition SmallSet.h:45
SmallSetIterator(VecIterTy VecIter)
Definition SmallSet.h:54
~SmallSetIterator()
Definition SmallSet.h:58
const T & operator*() const
Definition SmallSet.h:127
SmallSetIterator & operator++()
Definition SmallSet.h:119
SmallSetIterator & operator=(const SmallSetIterator &Other)
Definition SmallSet.h:83
VecIterTy VecIter
Definition SmallSet.h:46
SmallSetIterator(SmallSetIterator &&Other)
Definition SmallSet.h:74
SmallSetIterator & operator=(SmallSetIterator &&Other)
Definition SmallSet.h:97
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
iterator erase(const_iterator CI)
Definition SmallVector.h:753
void clear()
Definition SmallVector.h:626
void pop_back()
Definition SmallVector.h:441
void push_back(const T &Elt)
Definition SmallVector.h:429
size_t size() const
Definition SmallVector.h:99
iterator begin()
Definition SmallVector.h:283
T * iterator
Definition SmallVector.h:267
iterator end()
Definition SmallVector.h:285
const T * const_iterator
Definition SmallVector.h:268
bool empty() const
Definition SmallVector.h:102
reference back()
Definition SmallVector.h:324
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterator.h:80
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