LLVM  14.0.0git
llvm::FoldingSetBase Class Reference

FoldingSetBase - Implements the folding set functionality. More...

#include "llvm/ADT/FoldingSet.h"

Inheritance diagram for llvm::FoldingSetBase:
[legend]
Collaboration diagram for llvm::FoldingSetBase:
[legend]

## 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. More...

unsigned size () const
size - Returns the number of nodes in the folding set. More...

bool empty () const
empty - Returns true if there are no nodes in the folding set. More...

unsigned capacity ()
capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is performed. More...

## Protected Member Functions

FoldingSetBase (unsigned Log2InitSize=6)

FoldingSetBase (FoldingSetBase &&Arg)

FoldingSetBaseoperator= (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. More...

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. More...

NodeGetOrInsertNode (Node *N, const FoldingSetInfo &Info)
GetOrInsertNode - If there is an existing simple Node exactly equal to the specified node, return it. More...

NodeFindNodeOrInsertPos (const FoldingSetNodeID &ID, void *&InsertPos, const FoldingSetInfo &Info)
FindNodeOrInsertPos - Look up the node specified by ID. More...

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. More...

## Protected Attributes

void ** Buckets
Buckets - Array of bucket chains. More...

unsigned NumBuckets
NumBuckets - Length of the Buckets array. Always a power of 2. More...

unsigned NumNodes
NumNodes - Number of nodes in the folding set. More...

## Detailed Description

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 112 of file FoldingSet.h.

## ◆ FoldingSetBase() [1/2]

 FoldingSetBase::FoldingSetBase ( unsigned Log2InitSize = 6 )
explicitprotected

Definition at line 231 of file FoldingSet.cpp.

References AllocateBuckets(), assert(), Buckets, NumBuckets, and NumNodes.

## ◆ FoldingSetBase() [2/2]

 FoldingSetBase::FoldingSetBase ( FoldingSetBase && Arg )
protected

Definition at line 239 of file FoldingSet.cpp.

References Arg.

## ◆ ~FoldingSetBase()

 FoldingSetBase::~FoldingSetBase ( )
protected

Definition at line 257 of file FoldingSet.cpp.

References Buckets.

## ◆ capacity()

 unsigned llvm::FoldingSetBase::capacity ( )
inline

capacity - Returns the number of nodes permitted in the folding set before a rebucket operation is performed.

Definition at line 157 of file FoldingSet.h.

References NumBuckets.

Referenced by InsertNode(), and reserve().

## ◆ clear()

 void FoldingSetBase::clear ( )

clear - Remove all nodes from the folding set.

Definition at line 261 of file FoldingSet.cpp.

References Buckets, NumBuckets, and NumNodes.

Referenced by llvm::FoldingSetVector< T, VectorT >::clear().

## ◆ empty()

 bool llvm::FoldingSetBase::empty ( ) const
inline

empty - Returns true if there are no nodes in the folding set.

Definition at line 153 of file FoldingSet.h.

References NumNodes.

Referenced by llvm::FoldingSetVector< T, VectorT >::empty().

## ◆ FindNodeOrInsertPos()

 FoldingSetBase::Node * FoldingSetBase::FindNodeOrInsertPos ( const FoldingSetNodeID & ID, void *& InsertPos, const FoldingSetInfo & Info )
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 326 of file FoldingSet.cpp.

References Buckets, llvm::FoldingSetNodeID::clear(), GetBucketFor(), GetNextPtr(), Info, and NumBuckets.

## ◆ GetOrInsertNode()

 FoldingSetBase::Node * FoldingSetBase::GetOrInsertNode ( FoldingSetBase::Node * N, const FoldingSetInfo & Info )
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 424 of file FoldingSet.cpp.

References E, FindNodeOrInsertPos(), Info, InsertNode(), and N.

## ◆ InsertNode()

 void FoldingSetBase::InsertNode ( Node * N, void * InsertPos, const FoldingSetInfo & Info )
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 351 of file FoldingSet.cpp.

References assert(), Buckets, capacity(), GetBucketFor(), Info, N, NumBuckets, and NumNodes.

## ◆ operator=()

 FoldingSetBase & FoldingSetBase::operator= ( FoldingSetBase && RHS )
protected

Definition at line 246 of file FoldingSet.cpp.

References Buckets, NumBuckets, and NumNodes.

## ◆ RemoveNode()

 bool FoldingSetBase::RemoveNode ( Node * N )
protected

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 382 of file FoldingSet.cpp.

References GetBucketPtr(), GetNextPtr(), N, and NumNodes.

## ◆ reserve()

 void FoldingSetBase::reserve ( unsigned EltCount, const FoldingSetInfo & Info )
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 314 of file FoldingSet.cpp.

References capacity(), Info, and llvm::PowerOf2Floor().

## ◆ size()

 unsigned llvm::FoldingSetBase::size ( ) const
inline

size - Returns the number of nodes in the folding set.

Definition at line 150 of file FoldingSet.h.

References NumNodes.

Referenced by llvm::FoldingSetVector< T, VectorT >::size().

## ◆ Buckets

 void** llvm::FoldingSetBase::Buckets
protected

Buckets - Array of bucket chains.

Definition at line 115 of file FoldingSet.h.

## ◆ NumBuckets

 unsigned llvm::FoldingSetBase::NumBuckets
protected

NumBuckets - Length of the Buckets array. Always a power of 2.

Definition at line 118 of file FoldingSet.h.

## ◆ NumNodes

 unsigned llvm::FoldingSetBase::NumNodes
protected

NumNodes - Number of nodes in the folding set.

Growth occurs when NumNodes is greater than twice the number of buckets.

Definition at line 122 of file FoldingSet.h.

Referenced by clear(), empty(), FoldingSetBase(), InsertNode(), operator=(), RemoveNode(), and size().

The documentation for this class was generated from the following files: