/home/arjun/llvm-project/llvm/include/llvm/ADT/StringSet.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===- StringSet.h - An efficient set built on StringMap --------*- C++ -*-===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // StringSet - A set-like wrapper for the StringMap. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | |
13 | | #ifndef LLVM_ADT_STRINGSET_H |
14 | | #define LLVM_ADT_STRINGSET_H |
15 | | |
16 | | #include "llvm/ADT/StringMap.h" |
17 | | |
18 | | namespace llvm { |
19 | | |
20 | | /// StringSet - A wrapper for StringMap that provides set-like functionality. |
21 | | template <class AllocatorTy = MallocAllocator> |
22 | | class StringSet : public StringMap<NoneType, AllocatorTy> { |
23 | | using Base = StringMap<NoneType, AllocatorTy>; |
24 | | |
25 | | public: |
26 | 0 | StringSet() = default; |
27 | | StringSet(std::initializer_list<StringRef> initializer) { |
28 | | for (StringRef str : initializer) |
29 | | insert(str); |
30 | | } |
31 | 0 | explicit StringSet(AllocatorTy a) : Base(a) {} |
32 | | |
33 | 0 | std::pair<typename Base::iterator, bool> insert(StringRef key) { |
34 | 0 | return Base::try_emplace(key); |
35 | 0 | } Unexecuted instantiation: _ZN4llvm9StringSetINS_15MallocAllocatorEE6insertENS_9StringRefE Unexecuted instantiation: _ZN4llvm9StringSetIRNS_20BumpPtrAllocatorImplINS_15MallocAllocatorELm4096ELm4096ELm128EEEE6insertENS_9StringRefE |
36 | | |
37 | | template <typename InputIt> |
38 | | void insert(const InputIt &begin, const InputIt &end) { |
39 | | for (auto it = begin; it != end; ++it) |
40 | | insert(*it); |
41 | | } |
42 | | |
43 | | template <typename ValueTy> |
44 | | std::pair<typename Base::iterator, bool> |
45 | | insert(const StringMapEntry<ValueTy> &mapEntry) { |
46 | | return insert(mapEntry.getKey()); |
47 | | } |
48 | | }; |
49 | | |
50 | | } // end namespace llvm |
51 | | |
52 | | #endif // LLVM_ADT_STRINGSET_H |