llvm.org GIT mirror llvm / 18b6910
add some comments on the algorithm git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33579 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
1 changed file(s) with 20 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
66 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file defines the SmallPtrSet class.
9 // This file defines the SmallPtrSet class. See the doxygen comment for
10 // SmallPtrSetImpl for more details on the algorithm used.
1011 //
1112 //===----------------------------------------------------------------------===//
1213
1819
1920 namespace llvm {
2021
22 /// SmallPtrSetImpl - This is the common code shared among all the
23 /// SmallPtrSet<>'s, which is almost everything. SmallPtrSet has two modes, one
24 /// for small and one for large sets.
25 ///
26 /// Small sets use an array of pointers allocated in the SmallPtrSet object,
27 /// which is treated as a simple array of pointers. When a pointer is added to
28 /// the set, the array is scanned to see if the element already exists, if not
29 /// the element is 'pushed back' onto the array. If we run out of space in the
30 /// array, we grow into the 'large set' case. SmallSet should be used when the
31 /// sets are often small. In this case, no memory allocation is used, and only
32 /// light-weight and cache-efficient scanning is used.
33 ///
34 /// Large sets use a classic exponentially-probed hash table. Empty buckets are
35 /// represented with an illegal pointer value (-1) to allow null pointers to be
36 /// inserted. Tombstones are represented with another illegal pointer value
37 /// (-2), to allow deletion. The hash table is resized when the table is 3/4 or
38 /// more. When this happens, the table is doubled in size.
39 ///
2140 class SmallPtrSetImpl {
2241 protected:
2342 /// CurArray - This is the current set of buckets. If it points to