003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/include/llvm/ADT
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
include
/
llvm
/
ADT
/
📁
..
📄
APFloat.h
(48.83 KB)
📄
APInt.h
(74.48 KB)
📄
APSInt.h
(11.75 KB)
📄
AllocatorList.h
(7.53 KB)
📄
Any.h
(5.05 KB)
📄
ArrayRef.h
(17.92 KB)
📄
BitVector.h
(29.74 KB)
📄
Bitfields.h
(11.65 KB)
📄
BitmaskEnum.h
(5.53 KB)
📄
BreadthFirstIterator.h
(4.82 KB)
📄
CachedHashString.h
(5.9 KB)
📄
CoalescingBitVector.h
(14.91 KB)
📄
DAGDeltaAlgorithm.h
(3.13 KB)
📄
DeltaAlgorithm.h
(3.54 KB)
📄
DenseMap.h
(43.14 KB)
📄
DenseMapInfo.h
(11.4 KB)
📄
DenseSet.h
(9.33 KB)
📄
DepthFirstIterator.h
(10.37 KB)
📄
DirectedGraph.h
(9.56 KB)
📄
EnumeratedArray.h
(1.6 KB)
📄
EpochTracker.h
(3.2 KB)
📄
EquivalenceClasses.h
(10.52 KB)
📄
FloatingPointMode.h
(5.62 KB)
📄
FoldingSet.h
(30.16 KB)
📄
FunctionExtras.h
(14.55 KB)
📄
GraphTraits.h
(5.71 KB)
📄
Hashing.h
(25.12 KB)
📄
ImmutableList.h
(7.57 KB)
📄
ImmutableMap.h
(10.84 KB)
📄
ImmutableSet.h
(37.52 KB)
📄
IndexedMap.h
(2.5 KB)
📄
IntEqClasses.h
(2.87 KB)
📄
IntervalMap.h
(72.88 KB)
📄
IntrusiveRefCntPtr.h
(8.1 KB)
📄
MapVector.h
(7.79 KB)
📄
None.h
(983 B)
📄
Optional.h
(10.82 KB)
📄
PackedVector.h
(4.17 KB)
📄
PointerEmbeddedInt.h
(4.05 KB)
📄
PointerIntPair.h
(8.72 KB)
📄
PointerSumType.h
(11.61 KB)
📄
PointerUnion.h
(10.17 KB)
📄
PostOrderIterator.h
(11.05 KB)
📄
PriorityQueue.h
(2.69 KB)
📄
PriorityWorklist.h
(8.11 KB)
📄
SCCIterator.h
(8.02 KB)
📄
STLExtras.h
(70.56 KB)
📄
ScopeExit.h
(1.83 KB)
📄
ScopedHashTable.h
(8.27 KB)
📄
Sequence.h
(2.59 KB)
📄
SetOperations.h
(2.58 KB)
📄
SetVector.h
(9.39 KB)
📄
SmallBitVector.h
(20.36 KB)
📄
SmallPtrSet.h
(16.93 KB)
📄
SmallSet.h
(8.37 KB)
📄
SmallString.h
(8.55 KB)
📄
SmallVector.h
(32.33 KB)
📄
SparseBitVector.h
(26.2 KB)
📄
SparseMultiSet.h
(17.83 KB)
📄
SparseSet.h
(11.41 KB)
📄
Statistic.h
(7.01 KB)
📄
StringExtras.h
(13.25 KB)
📄
StringMap.h
(15.7 KB)
📄
StringMapEntry.h
(4.83 KB)
📄
StringRef.h
(31.68 KB)
📄
StringSet.h
(1.51 KB)
📄
StringSwitch.h
(6.25 KB)
📄
TinyPtrVector.h
(10.19 KB)
📄
Triple.h
(27.4 KB)
📄
Twine.h
(17.48 KB)
📄
TypeSwitch.h
(5.82 KB)
📄
UniqueVector.h
(3.09 KB)
📄
Waymarking.h
(11.96 KB)
📄
bit.h
(2.26 KB)
📄
edit_distance.h
(3.57 KB)
📄
fallible_iterator.h
(8.31 KB)
📄
ilist.h
(13.68 KB)
📄
ilist_base.h
(2.72 KB)
📄
ilist_iterator.h
(7.21 KB)
📄
ilist_node.h
(9.84 KB)
📄
ilist_node_base.h
(1.7 KB)
📄
ilist_node_options.h
(5.07 KB)
📄
iterator.h
(13.46 KB)
📄
iterator_range.h
(2.22 KB)
📄
simple_ilist.h
(10.78 KB)
Editing: DenseSet.h
//===- llvm/ADT/DenseSet.h - Dense probed hash table ------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file defines the DenseSet and SmallDenseSet classes. // //===----------------------------------------------------------------------===// #ifndef LLVM_ADT_DENSESET_H #define LLVM_ADT_DENSESET_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/type_traits.h" #include <algorithm> #include <cstddef> #include <initializer_list> #include <iterator> #include <utility> namespace llvm { namespace detail { struct DenseSetEmpty {}; // Use the empty base class trick so we can create a DenseMap where the buckets // contain only a single item. template <typename KeyT> class DenseSetPair : public DenseSetEmpty { KeyT key; public: KeyT &getFirst() { return key; } const KeyT &getFirst() const { return key; } DenseSetEmpty &getSecond() { return *this; } const DenseSetEmpty &getSecond() const { return *this; } }; /// Base class for DenseSet and DenseSmallSet. /// /// MapTy should be either /// /// DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT, /// detail::DenseSetPair<ValueT>> /// /// or the equivalent SmallDenseMap type. ValueInfoT must implement the /// DenseMapInfo "concept". template <typename ValueT, typename MapTy, typename ValueInfoT> class DenseSetImpl { static_assert(sizeof(typename MapTy::value_type) == sizeof(ValueT), "DenseMap buckets unexpectedly large!"); MapTy TheMap; template <typename T> using const_arg_type_t = typename const_pointer_or_const_ref<T>::type; public: using key_type = ValueT; using value_type = ValueT; using size_type = unsigned; explicit DenseSetImpl(unsigned InitialReserve = 0) : TheMap(InitialReserve) {} template <typename InputIt> DenseSetImpl(const InputIt &I, const InputIt &E) : DenseSetImpl(PowerOf2Ceil(std::distance(I, E))) { insert(I, E); } DenseSetImpl(std::initializer_list<ValueT> Elems) : DenseSetImpl(PowerOf2Ceil(Elems.size())) { insert(Elems.begin(), Elems.end()); } bool empty() const { return TheMap.empty(); } size_type size() const { return TheMap.size(); } size_t getMemorySize() const { return TheMap.getMemorySize(); } /// Grow the DenseSet so that it has at least Size buckets. Will not shrink /// the Size of the set. void resize(size_t Size) { TheMap.resize(Size); } /// Grow the DenseSet so that it can contain at least \p NumEntries items /// before resizing again. void reserve(size_t Size) { TheMap.reserve(Size); } void clear() { TheMap.clear(); } /// Return 1 if the specified key is in the set, 0 otherwise. size_type count(const_arg_type_t<ValueT> V) const { return TheMap.count(V); } bool erase(const ValueT &V) { return TheMap.erase(V); } void swap(DenseSetImpl &RHS) { TheMap.swap(RHS.TheMap); } // Iterators. class ConstIterator; class Iterator { typename MapTy::iterator I; friend class DenseSetImpl; friend class ConstIterator; public: using difference_type = typename MapTy::iterator::difference_type; using value_type = ValueT; using pointer = value_type *; using reference = value_type &; using iterator_category = std::forward_iterator_tag; Iterator() = default; Iterator(const typename MapTy::iterator &i) : I(i) {} ValueT &operator*() { return I->getFirst(); } const ValueT &operator*() const { return I->getFirst(); } ValueT *operator->() { return &I->getFirst(); } const ValueT *operator->() const { return &I->getFirst(); } Iterator& operator++() { ++I; return *this; } Iterator operator++(int) { auto T = *this; ++I; return T; } bool operator==(const ConstIterator& X) const { return I == X.I; } bool operator!=(const ConstIterator& X) const { return I != X.I; } }; class ConstIterator { typename MapTy::const_iterator I; friend class DenseSetImpl; friend class Iterator; public: using difference_type = typename MapTy::const_iterator::difference_type; using value_type = ValueT; using pointer = const value_type *; using reference = const value_type &; using iterator_category = std::forward_iterator_tag; ConstIterator() = default; ConstIterator(const Iterator &B) : I(B.I) {} ConstIterator(const typename MapTy::const_iterator &i) : I(i) {} const ValueT &operator*() const { return I->getFirst(); } const ValueT *operator->() const { return &I->getFirst(); } ConstIterator& operator++() { ++I; return *this; } ConstIterator operator++(int) { auto T = *this; ++I; return T; } bool operator==(const ConstIterator& X) const { return I == X.I; } bool operator!=(const ConstIterator& X) const { return I != X.I; } }; using iterator = Iterator; using const_iterator = ConstIterator; iterator begin() { return Iterator(TheMap.begin()); } iterator end() { return Iterator(TheMap.end()); } const_iterator begin() const { return ConstIterator(TheMap.begin()); } const_iterator end() const { return ConstIterator(TheMap.end()); } iterator find(const_arg_type_t<ValueT> V) { return Iterator(TheMap.find(V)); } const_iterator find(const_arg_type_t<ValueT> V) const { return ConstIterator(TheMap.find(V)); } /// Alternative version of find() which allows a different, and possibly less /// expensive, key type. /// The DenseMapInfo is responsible for supplying methods /// getHashValue(LookupKeyT) and isEqual(LookupKeyT, KeyT) for each key type /// used. template <class LookupKeyT> iterator find_as(const LookupKeyT &Val) { return Iterator(TheMap.find_as(Val)); } template <class LookupKeyT> const_iterator find_as(const LookupKeyT &Val) const { return ConstIterator(TheMap.find_as(Val)); } void erase(Iterator I) { return TheMap.erase(I.I); } void erase(ConstIterator CI) { return TheMap.erase(CI.I); } std::pair<iterator, bool> insert(const ValueT &V) { detail::DenseSetEmpty Empty; return TheMap.try_emplace(V, Empty); } std::pair<iterator, bool> insert(ValueT &&V) { detail::DenseSetEmpty Empty; return TheMap.try_emplace(std::move(V), Empty); } /// Alternative version of insert that uses a different (and possibly less /// expensive) key type. template <typename LookupKeyT> std::pair<iterator, bool> insert_as(const ValueT &V, const LookupKeyT &LookupKey) { return TheMap.insert_as({V, detail::DenseSetEmpty()}, LookupKey); } template <typename LookupKeyT> std::pair<iterator, bool> insert_as(ValueT &&V, const LookupKeyT &LookupKey) { return TheMap.insert_as({std::move(V), detail::DenseSetEmpty()}, LookupKey); } // Range insertion of values. template<typename InputIt> void insert(InputIt I, InputIt E) { for (; I != E; ++I) insert(*I); } }; /// Equality comparison for DenseSet. /// /// Iterates over elements of LHS confirming that each element is also a member /// of RHS, and that RHS contains no additional values. /// Equivalent to N calls to RHS.count. Amortized complexity is linear, worst /// case is O(N^2) (if every hash collides). template <typename ValueT, typename MapTy, typename ValueInfoT> bool operator==(const DenseSetImpl<ValueT, MapTy, ValueInfoT> &LHS, const DenseSetImpl<ValueT, MapTy, ValueInfoT> &RHS) { if (LHS.size() != RHS.size()) return false; for (auto &E : LHS) if (!RHS.count(E)) return false; return true; } /// Inequality comparison for DenseSet. /// /// Equivalent to !(LHS == RHS). See operator== for performance notes. template <typename ValueT, typename MapTy, typename ValueInfoT> bool operator!=(const DenseSetImpl<ValueT, MapTy, ValueInfoT> &LHS, const DenseSetImpl<ValueT, MapTy, ValueInfoT> &RHS) { return !(LHS == RHS); } } // end namespace detail /// Implements a dense probed hash-table based set. template <typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT>> class DenseSet : public detail::DenseSetImpl< ValueT, DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair<ValueT>>, ValueInfoT> { using BaseT = detail::DenseSetImpl<ValueT, DenseMap<ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair<ValueT>>, ValueInfoT>; public: using BaseT::BaseT; }; /// Implements a dense probed hash-table based set with some number of buckets /// stored inline. template <typename ValueT, unsigned InlineBuckets = 4, typename ValueInfoT = DenseMapInfo<ValueT>> class SmallDenseSet : public detail::DenseSetImpl< ValueT, SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets, ValueInfoT, detail::DenseSetPair<ValueT>>, ValueInfoT> { using BaseT = detail::DenseSetImpl< ValueT, SmallDenseMap<ValueT, detail::DenseSetEmpty, InlineBuckets, ValueInfoT, detail::DenseSetPair<ValueT>>, ValueInfoT>; public: using BaseT::BaseT; }; } // end namespace llvm #endif // LLVM_ADT_DENSESET_H
Upload File
Create Folder