LLVM 18.0.0git
|
FoldingSetBase - Implements the folding set functionality. More...
#include "llvm/ADT/FoldingSet.h"
Classes | |
struct | FoldingSetInfo |
Functions provided by the derived class to compute folding properties. More... | |
class | Node |
Node - This class is used to maintain the singly linked bucket list in a folding set. More... | |
Public Member Functions | |
void | clear () |
clear - Remove all nodes from the folding set. | |
unsigned | size () const |
size - Returns the number of nodes in the folding set. | |
bool | empty () const |
empty - Returns true if there are no nodes in the folding set. | |
unsigned | capacity () |
capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is performed. | |
Protected Member Functions | |
FoldingSetBase (unsigned Log2InitSize=6) | |
FoldingSetBase (FoldingSetBase &&Arg) | |
FoldingSetBase & | operator= (FoldingSetBase &&RHS) |
~FoldingSetBase () | |
void | reserve (unsigned EltCount, const FoldingSetInfo &Info) |
reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket operation. | |
bool | RemoveNode (Node *N) |
RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the node was not in the folding set. | |
Node * | GetOrInsertNode (Node *N, const FoldingSetInfo &Info) |
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node, return it. | |
Node * | FindNodeOrInsertPos (const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info) |
FindNodeOrInsertPos - Look up the node specified by ID. | |
void | InsertNode (Node *N, void *InsertPos, const FoldingSetInfo &Info) |
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the folding set. | |
Protected Attributes | |
void ** | Buckets |
Buckets - Array of bucket chains. | |
unsigned | NumBuckets |
NumBuckets - Length of the Buckets array. Always a power of 2. | |
unsigned | NumNodes |
NumNodes - Number of nodes in the folding set. | |
FoldingSetBase - Implements the folding set functionality.
The main structure is an array of buckets. Each bucket is indexed by the hash of the nodes it contains. The bucket itself points to the nodes contained in the bucket via a singly linked list. The last node in the list points back to the bucket to facilitate node removal.
Definition at line 116 of file FoldingSet.h.
|
explicitprotected |
Definition at line 183 of file FoldingSet.cpp.
References AllocateBuckets(), assert(), Buckets, NumBuckets, and NumNodes.
|
protected |
Definition at line 191 of file FoldingSet.cpp.
|
protected |
Definition at line 209 of file FoldingSet.cpp.
References Buckets.
|
inline |
capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is performed.
Definition at line 161 of file FoldingSet.h.
References NumBuckets.
Referenced by InsertNode(), and reserve().
void FoldingSetBase::clear | ( | ) |
clear - Remove all nodes from the folding set.
Definition at line 213 of file FoldingSet.cpp.
References Buckets, NumBuckets, and NumNodes.
Referenced by llvm::FoldingSetVector< T, VectorT >::clear().
|
inline |
empty - Returns true if there are no nodes in the folding set.
Definition at line 157 of file FoldingSet.h.
References NumNodes.
Referenced by llvm::FoldingSetVector< T, VectorT >::empty().
|
protected |
FindNodeOrInsertPos - Look up the node specified by ID.
If it exists, return it. If not, return the insertion token that will make insertion faster.
Definition at line 278 of file FoldingSet.cpp.
References Buckets, llvm::FoldingSetNodeID::clear(), GetBucketFor(), GetNextPtr(), Info, and NumBuckets.
Referenced by llvm::FoldingSetImpl< Derived, T >::FindNodeOrInsertPos(), and GetOrInsertNode().
|
protected |
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node, return it.
Otherwise, insert 'N' and return it instead.
Otherwise, insert 'N' and it instead.
Definition at line 376 of file FoldingSet.cpp.
References E, FindNodeOrInsertPos(), Info, InsertNode(), and N.
Referenced by llvm::FoldingSetImpl< Derived, T >::GetOrInsertNode().
|
protected |
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the folding set.
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the map.
InsertPos must be obtained from FindNodeOrInsertPos.
The insert position is actually a bucket pointer.
Definition at line 303 of file FoldingSet.cpp.
References assert(), Buckets, capacity(), GetBucketFor(), Info, N, NumBuckets, and NumNodes.
Referenced by GetOrInsertNode(), and llvm::FoldingSetImpl< Derived, T >::InsertNode().
|
protected |
Definition at line 198 of file FoldingSet.cpp.
References Buckets, NumBuckets, NumNodes, and RHS.
RemoveNode - Remove a node from the folding set, returning true if one was removed or false if the node was not in the folding set.
Definition at line 334 of file FoldingSet.cpp.
References GetBucketPtr(), GetNextPtr(), N, NumNodes, and Ptr.
Referenced by llvm::FoldingSetImpl< Derived, T >::RemoveNode().
|
protected |
reserve - Increase the number of buckets such that adding the EltCount-th node won't cause a rebucket operation.
reserve is permitted to allocate more space than requested by EltCount.
Definition at line 266 of file FoldingSet.cpp.
References llvm::bit_floor(), capacity(), and Info.
Referenced by llvm::FoldingSetImpl< Derived, T >::reserve().
|
inline |
size - Returns the number of nodes in the folding set.
Definition at line 154 of file FoldingSet.h.
References NumNodes.
Referenced by llvm::FoldingSetVector< T, VectorT >::size().
|
protected |
Buckets - Array of bucket chains.
Definition at line 119 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< Derived, T >::begin(), llvm::FoldingSetImpl< Derived, T >::bucket_begin(), llvm::FoldingSetImpl< Derived, T >::bucket_end(), clear(), llvm::FoldingSetImpl< Derived, T >::end(), FindNodeOrInsertPos(), FoldingSetBase(), InsertNode(), operator=(), and ~FoldingSetBase().
|
protected |
NumBuckets - Length of the Buckets array. Always a power of 2.
Definition at line 122 of file FoldingSet.h.
Referenced by llvm::FoldingSetImpl< Derived, T >::bucket_begin(), llvm::FoldingSetImpl< Derived, T >::bucket_end(), capacity(), clear(), llvm::FoldingSetImpl< Derived, T >::end(), FindNodeOrInsertPos(), FoldingSetBase(), InsertNode(), and operator=().
|
protected |
NumNodes - Number of nodes in the folding set.
Growth occurs when NumNodes is greater than twice the number of buckets.
Definition at line 126 of file FoldingSet.h.
Referenced by clear(), empty(), FoldingSetBase(), InsertNode(), operator=(), RemoveNode(), and size().