1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===- StringSet.h - The LLVM Compiler Driver -------------------*- C++ -*-===// 2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// The LLVM Compiler Infrastructure 4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open 6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// Source License. See LICENSE.TXT for details. 7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===// 9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// StringSet - A set-like wrapper for the StringMap. 11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// 12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===// 13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_ADT_STRINGSET_H 15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_ADT_STRINGSET_H 16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringMap.h" 18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/ADT/StringRef.h" 19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Support/Allocator.h" 20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <cassert> 21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <initializer_list> 22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include <utility> 23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm { 25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot /// StringSet - A wrapper for StringMap that provides set-like functionality. 27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot template <class AllocatorTy = MallocAllocator> 28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot class StringSet : public StringMap<char, AllocatorTy> { 29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot using base = StringMap<char, AllocatorTy>; 30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot public: 32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringSet() = default; 33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot StringSet(std::initializer_list<StringRef> S) { 34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (StringRef X : S) 35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot insert(X); 36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot std::pair<typename base::iterator, bool> insert(StringRef Key) { 39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot assert(!Key.empty()); 40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot return base::insert(std::make_pair(Key, '\0')); 41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot template <typename InputIt> 44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot void insert(const InputIt &Begin, const InputIt &End) { 45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot for (auto It = Begin; It != End; ++It) 46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot base::insert(std::make_pair(*It, '\0')); 47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot } 48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot }; 49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // end namespace llvm 51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot 52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif // LLVM_ADT_STRINGSET_H 53