aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/ADT/SmallMap.h
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-04-25 17:09:38 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-04-25 17:09:38 +0000
commit76271a3366731d4c372fdebcd8d3437e6e09a61b (patch)
tree753cad255078a61246190aa77b8360ee685af238 /include/llvm/ADT/SmallMap.h
parent50e1d84ba8efc1973137c65e0b0e048ecf8cf5d6 (diff)
First implementation of:
- FlatArrayMap. Very simple map container that uses flat array inside. - MultiImplMap. Map container interface, that has two modes, one for small amount of elements and one for big amount. - SmallMap. SmallMap is DenseMap compatible MultiImplMap. It uses FlatArrayMap for small mode, and DenseMap for big mode. Also added unittests for new classes and update for ProgrammersManual. For more details about new classes see ProgrammersManual and comments in sourcecode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/SmallMap.h')
-rw-r--r--include/llvm/ADT/SmallMap.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/llvm/ADT/SmallMap.h b/include/llvm/ADT/SmallMap.h
new file mode 100644
index 0000000000..3bfb1556ca
--- /dev/null
+++ b/include/llvm/ADT/SmallMap.h
@@ -0,0 +1,37 @@
+//===- llvm/ADT/SmallMap.h - 'Normally small' pointer set -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the SmallMap class.
+// SmallMap is DenseMap compatible MultiImplMap.
+// It uses FlatArrayMap for small mode, and DenseMap for big mode.
+// See MultiMapImpl comments for more details on the algorithm is used.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SMALLPTRMAP_H_
+#define SMALLPTRMAP_H_
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/FlatArrayMap.h"
+#include "llvm/ADT/MultiImplMap.h"
+
+namespace llvm {
+
+ //===--------------------------------------------------------------------===//
+ /// SmallMap is wrapper around MultiImplMap. It uses FlatArrayMap for
+ /// small mode, and DenseMap for big mode.
+ template <typename KeyTy, typename MappedTy, unsigned N = 16>
+ class SmallMap : public MultiImplMap<
+ FlatArrayMap<KeyTy, MappedTy, N>,
+ DenseMap<KeyTy, MappedTy>,
+ N, true> {
+ };
+}
+
+#endif /* SMALLPTRMAP_H_ */