1 //===- llvm/ADT/DenseSet.h - Dense probed hash table ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by Chris Lattner and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the DenseSet class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_ADT_DENSESET_H
15 #define LLVM_ADT_DENSESET_H
17 #include "llvm/ADT/DenseMap.h"
21 /// DenseSet - This implements a dense probed hash-table based set.
23 /// FIXME: This is currently implemented directly in terms of DenseMap, this
24 /// should be optimized later if there is a need.
25 template<typename ValueT, typename ValueInfoT = DenseMapInfo<ValueT> >
27 DenseMap<ValueT, char, ValueInfoT> TheMap;
29 DenseSet(const DenseSet &Other) : TheMap(Other.TheMap) {}
30 explicit DenseSet(unsigned NumInitBuckets = 64) : TheMap(NumInitBuckets) {}
32 bool empty() const { return TheMap.empty(); }
33 unsigned size() const { return TheMap.size(); }
35 // TODO add iterators.
41 bool count(const ValueT &V) const {
42 return TheMap.count(V);
45 void insert(const ValueT &V) {
49 void erase(const ValueT &V) {
53 DenseSet &operator=(const DenseSet &RHS) {
59 } // end namespace llvm