LLVM  4.0.0
StringSet.h
Go to the documentation of this file.
1 //===--- StringSet.h - The LLVM Compiler Driver -----------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // StringSet - A set-like wrapper for the StringMap.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_ADT_STRINGSET_H
15 #define LLVM_ADT_STRINGSET_H
16 
17 #include "llvm/ADT/StringMap.h"
18 
19 namespace llvm {
20 
21  /// StringSet - A wrapper for StringMap that provides set-like functionality.
22  template <class AllocatorTy = llvm::MallocAllocator>
23  class StringSet : public llvm::StringMap<char, AllocatorTy> {
25  public:
26  StringSet() = default;
27  StringSet(std::initializer_list<StringRef> S) {
28  for (StringRef X : S)
29  insert(X);
30  }
31 
32  std::pair<typename base::iterator, bool> insert(StringRef Key) {
33  assert(!Key.empty());
34  return base::insert(std::make_pair(Key, '\0'));
35  }
36 
37  template <typename InputIt>
38  void insert(const InputIt &Begin, const InputIt &End) {
39  for (auto It = Begin; It != End; ++It)
40  base::insert(std::make_pair(*It, '\0'));
41  }
42  };
43 }
44 
45 #endif // LLVM_ADT_STRINGSET_H
StringSet(std::initializer_list< StringRef > S)
Definition: StringSet.h:27
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
static const unsigned End
std::pair< typename base::iterator, bool > insert(StringRef Key)
Definition: StringSet.h:32
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:348
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:223
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:130
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
StringSet - A wrapper for StringMap that provides set-like functionality.
Definition: StringSet.h:23
StringSet()=default
void insert(const InputIt &Begin, const InputIt &End)
Definition: StringSet.h:38
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47