Deleted Added
full compact
StringSet.h (243830) StringSet.h (249423)
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//===----------------------------------------------------------------------===//

--- 4 unchanged lines hidden (view full) ---

13
14#ifndef LLVM_ADT_STRINGSET_H
15#define LLVM_ADT_STRINGSET_H
16
17#include "llvm/ADT/StringMap.h"
18
19namespace llvm {
20
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//===----------------------------------------------------------------------===//

--- 4 unchanged lines hidden (view full) ---

13
14#ifndef LLVM_ADT_STRINGSET_H
15#define LLVM_ADT_STRINGSET_H
16
17#include "llvm/ADT/StringMap.h"
18
19namespace llvm {
20
21 /// StringSet - A wrapper for StringMap that provides set-like
22 /// functionality. Only insert() and count() methods are used by my
23 /// code.
21 /// StringSet - A wrapper for StringMap that provides set-like functionality.
24 template <class AllocatorTy = llvm::MallocAllocator>
25 class StringSet : public llvm::StringMap<char, AllocatorTy> {
26 typedef llvm::StringMap<char, AllocatorTy> base;
27 public:
22 template <class AllocatorTy = llvm::MallocAllocator>
23 class StringSet : public llvm::StringMap<char, AllocatorTy> {
24 typedef llvm::StringMap<char, AllocatorTy> base;
25 public:
28 bool insert(StringRef InLang) {
29 assert(!InLang.empty());
30 const char *KeyStart = InLang.data();
31 const char *KeyEnd = KeyStart + InLang.size();
32 llvm::StringMapEntry<char> *Entry = llvm::StringMapEntry<char>::
33 Create(KeyStart, KeyEnd, base::getAllocator(), '+');
34 if (!base::insert(Entry)) {
35 Entry->Destroy(base::getAllocator());
26
27 /// insert - Insert the specified key into the set. If the key already
28 /// exists in the set, return false and ignore the request, otherwise insert
29 /// it and return true.
30 bool insert(StringRef Key) {
31 // Get or create the map entry for the key; if it doesn't exist the value
32 // type will be default constructed which we use to detect insert.
33 //
34 // We use '+' as the sentinel value in the map.
35 assert(!Key.empty());
36 StringMapEntry<char> &Entry = this->GetOrCreateValue(Key);
37 if (Entry.getValue() == '+')
36 return false;
38 return false;
37 }
39 Entry.setValue('+');
38 return true;
39 }
40 };
41}
42
43#endif // LLVM_ADT_STRINGSET_H
40 return true;
41 }
42 };
43}
44
45#endif // LLVM_ADT_STRINGSET_H