|
LLVM 24.0.0git
|
#include "llvm/ADT/ImmutableSet.h"
Public Member Functions | |
| ImutAVLFactory () | |
| ImutAVLFactory (BumpPtrAllocator &Alloc) | |
| ~ImutAVLFactory () | |
| TreeTy * | add (TreeTy *T, value_type_ref V) |
| template<typename CombineFn> | |
| TreeTy * | mergeTrees (TreeTy *A, TreeTy *B, CombineFn Combine, bool KeepUnmatched, bool SkipShared=false) |
Merges A and B in a single traversal, sharing every subtree that the two operands do not overlap. | |
| TreeTy * | unionTrees (TreeTy *A, TreeTy *B) |
Returns the set union of A and B (keeping A's element on matching keys). | |
| TreeTy * | remove (TreeTy *T, key_type_ref V) |
| template<typename PredFn> | |
| TreeTy * | filterTree (TreeTy *T, PredFn Pred) |
Returns the tree of the elements of T for which Pred holds. | |
| TreeTy * | getEmptyTree () const |
| TreeTy * | getCanonicalTree (TreeTy *TNew) |
Protected Member Functions | |
| bool | isEmpty (TreeTy *T) const |
| unsigned | getHeight (TreeTy *T) const |
| TreeTy * | getLeft (TreeTy *T) const |
| TreeTy * | getRight (TreeTy *T) const |
| value_type_ref | getValue (TreeTy *T) const |
| unsigned | incrementHeight (TreeTy *L, TreeTy *R) const |
| TreeTy * | createNode (TreeTy *L, value_type_ref V, TreeTy *R) |
| TreeTy * | createNode (TreeTy *newLeft, TreeTy *oldTree, TreeTy *newRight) |
| void | recoverNodes (TreeTy *Result) |
| TreeTy * | balanceTree (TreeTy *L, value_type_ref V, TreeTy *R) |
| Used by add_internal and remove_internal to balance a newly created tree. | |
| TreeTy * | joinTrees (TreeTy *L, value_type_ref V, TreeTy *R) |
Combines L and R with the value V (every key in L less than V, every key in R greater) into one balanced tree. | |
| void | splitLookup (TreeTy *T, key_type_ref K, TreeTy *&L, const value_type *&Match, TreeTy *&R) |
Splits T into L (all keys less than K) and R (all keys greater than K). | |
| template<typename CombineFn> | |
| TreeTy * | transformTree (TreeTy *T, CombineFn &Combine, bool FromB) |
Rebuilds T with the same shape but each element replaced by Combine applied to it. | |
| template<typename CombineFn> | |
| TreeTy * | merge_internal (TreeTy *A, TreeTy *B, CombineFn &Combine, bool KeepUnmatched, bool SkipShared) |
Merges A and B by recursing over A's structure and splitting B at each of A's keys. | |
| TreeTy * | add_internal (value_type_ref V, TreeTy *T) |
| add_internal - Creates a new tree that includes the specified data and the data from the original tree. | |
| TreeTy * | remove_internal (key_type_ref K, TreeTy *T) |
| remove_internal - Creates a new tree that includes all the data from the original tree except the specified data. | |
| TreeTy * | combineTrees (TreeTy *L, TreeTy *R) |
| TreeTy * | removeMinBinding (TreeTy *T, TreeTy *&Noderemoved) |
| template<typename PredFn> | |
| TreeTy * | filter_internal (TreeTy *T, PredFn &Pred) |
Static Protected Member Functions | |
| static unsigned | maskCacheIndex (unsigned I) |
Friends | |
| class | ImutAVLTree< ImutInfo, Canonicalize > |
Definition at line 401 of file ImmutableSet.h.
|
inline |
Definition at line 429 of file ImmutableSet.h.
|
inline |
Definition at line 432 of file ImmutableSet.h.
References llvm::Alloc.
|
inline |
Definition at line 435 of file ImmutableSet.h.
|
inline |
Definition at line 439 of file ImmutableSet.h.
References add_internal(), recoverNodes(), T, and V.
|
inlineprotected |
add_internal - Creates a new tree that includes the specified data and the data from the original tree.
If the original tree already contained the data item, the original tree is returned.
Definition at line 725 of file ImmutableSet.h.
References add_internal(), assert(), balanceTree(), createNode(), getLeft(), getRight(), getValue(), isEmpty(), T, and V.
Referenced by add(), and add_internal().
|
inlineprotected |
Used by add_internal and remove_internal to balance a newly created tree.
Definition at line 568 of file ImmutableSet.h.
References assert(), createNode(), getHeight(), getLeft(), getRight(), isEmpty(), and V.
Referenced by add_internal(), combineTrees(), joinTrees(), remove_internal(), and removeMinBinding().
|
inlineprotected |
Definition at line 785 of file ImmutableSet.h.
References balanceTree(), getValue(), isEmpty(), and removeMinBinding().
Referenced by remove_internal().
|
inlineprotected |
Definition at line 528 of file ImmutableSet.h.
References A(), assert(), incrementHeight(), T, and V.
Referenced by add_internal(), balanceTree(), createNode(), joinTrees(), and transformTree().
|
inlineprotected |
Definition at line 545 of file ImmutableSet.h.
References createNode(), and getValue().
|
inlineprotected |
Definition at line 805 of file ImmutableSet.h.
References filter_internal(), getLeft(), getRight(), getValue(), isEmpty(), joinTrees(), llvm::Keep, Pred, removeMinBinding(), and T.
Referenced by filter_internal(), and filterTree().
|
inline |
Returns the tree of the elements of T for which Pred holds.
Pred is called on the elements in order and must not use this factory. Subtrees that keep all of their elements are shared rather than rebuilt.
Definition at line 487 of file ImmutableSet.h.
References filter_internal(), Pred, recoverNodes(), and T.
|
inline |
|
inline |
Definition at line 493 of file ImmutableSet.h.
Referenced by splitLookup().
|
inlineprotected |
Definition at line 504 of file ImmutableSet.h.
References T.
Referenced by balanceTree(), incrementHeight(), and joinTrees().
|
inlineprotected |
Definition at line 505 of file ImmutableSet.h.
References T.
Referenced by add_internal(), balanceTree(), filter_internal(), joinTrees(), merge_internal(), remove_internal(), removeMinBinding(), splitLookup(), and transformTree().
|
inlineprotected |
Definition at line 506 of file ImmutableSet.h.
References T.
Referenced by add_internal(), balanceTree(), filter_internal(), joinTrees(), merge_internal(), remove_internal(), removeMinBinding(), splitLookup(), and transformTree().
|
inlineprotected |
Definition at line 507 of file ImmutableSet.h.
References T.
Referenced by add_internal(), combineTrees(), createNode(), filter_internal(), joinTrees(), merge_internal(), remove_internal(), removeMinBinding(), splitLookup(), and transformTree().
|
inlineprotected |
|
inlineprotected |
Definition at line 503 of file ImmutableSet.h.
References T.
Referenced by add_internal(), balanceTree(), combineTrees(), filter_internal(), merge_internal(), remove_internal(), removeMinBinding(), splitLookup(), and transformTree().
|
inlineprotected |
Combines L and R with the value V (every key in L less than V, every key in R greater) into one balanced tree.
Unlike balanceTree this tolerates an arbitrary height difference between L and R: it descends the taller side's spine and rebalances on the way back up, exactly as an insertion would.
Definition at line 614 of file ImmutableSet.h.
References balanceTree(), createNode(), getHeight(), getLeft(), getRight(), getValue(), joinTrees(), and V.
Referenced by filter_internal(), joinTrees(), merge_internal(), and splitLookup().
|
inlinestaticprotected |
|
inlineprotected |
Merges A and B by recursing over A's structure and splitting B at each of A's keys.
For a key in both, the stored element is Combine(AElem, BElem). KeepUnmatched controls keys unique to one side: when true, such elements (and whole non-overlapping subtrees) are taken unchanged and shared, and Combine is invoked only on keys present in both (valid when Combine is an identity for a missing side, e.g. a set union or a lattice join with an identity element); when false every key is passed through Combine with the absent side null (needed for a join that transforms unmatched keys, e.g. liveness downgrading Must to Maybe).
Definition at line 681 of file ImmutableSet.h.
References A(), B(), Combine, getLeft(), getRight(), getValue(), isEmpty(), joinTrees(), merge_internal(), splitLookup(), and transformTree().
Referenced by merge_internal(), and mergeTrees().
|
inline |
Merges A and B in a single traversal, sharing every subtree that the two operands do not overlap.
Combine(AElem, BElem) produces the element stored for a key present in both; KeepUnmatched governs keys unique to one side (see merge_internal). For merging |B| entries into |A| (|B| <= |A|) this costs O(|B| * log(|A|/|B| + 1)) and copies each spine node at most once, versus O(|B| * log|A|) repeated add descents. A and B must be immutable. This does not short-circuit equal or empty operands (merge_internal handles them correctly but not specially); callers that want those fast paths, or size-driven operand ordering, should apply them first (see ImmutableSet::Factory::unionSets).
Definition at line 456 of file ImmutableSet.h.
References A(), B(), Combine, merge_internal(), recoverNodes(), and T.
Referenced by unionTrees().
|
inlineprotected |
Definition at line 549 of file ImmutableSet.h.
References N, and llvm::reverse().
Referenced by add(), filterTree(), mergeTrees(), and remove().
|
inline |
Definition at line 478 of file ImmutableSet.h.
References recoverNodes(), remove_internal(), T, and V.
|
inlineprotected |
remove_internal - Creates a new tree that includes all the data from the original tree except the specified data.
If the specified data did not exist in the original tree, the original tree is returned.
Definition at line 760 of file ImmutableSet.h.
References assert(), balanceTree(), combineTrees(), getLeft(), getRight(), getValue(), isEmpty(), remove_internal(), and T.
Referenced by remove(), and remove_internal().
|
inlineprotected |
Definition at line 795 of file ImmutableSet.h.
References assert(), balanceTree(), getLeft(), getRight(), getValue(), isEmpty(), removeMinBinding(), and T.
Referenced by combineTrees(), filter_internal(), and removeMinBinding().
|
inlineprotected |
Splits T into L (all keys less than K) and R (all keys greater than K).
If K is present in T, Match is set to point at its element (which is dropped from L and R); otherwise Match is null.
Definition at line 625 of file ImmutableSet.h.
References getEmptyTree(), getLeft(), getRight(), getValue(), isEmpty(), joinTrees(), splitLookup(), and T.
Referenced by merge_internal(), and splitLookup().
|
inlineprotected |
Rebuilds T with the same shape but each element replaced by Combine applied to it.
FromB selects which side of Combine the element is passed on (it is the sole non-null argument). Subtrees that Combine leaves unchanged are shared.
Definition at line 656 of file ImmutableSet.h.
References Combine, createNode(), E(), getLeft(), getRight(), getValue(), isEmpty(), T, and transformTree().
Referenced by merge_internal(), and transformTree().
|
inline |
Returns the set union of A and B (keeping A's element on matching keys).
Shorthand for the fully sharing mergeTrees.
Definition at line 465 of file ImmutableSet.h.
References A(), B(), and mergeTrees().
|
friend |
Definition at line 391 of file ImmutableSet.h.
References llvm::Tree.