Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 31 lines (24 sloc) 0.756 kb
6d713f5 @andrewrk handle structural equivalence correctly
authored
1 #ifndef INSENSITIVE_MAP_H
2 #define INSENSITIVE_MAP_H
b9cf6ab @thejoshwolfe started implementing an insensitive map. so far, it's still sensitive
thejoshwolfe authored
3
4 #include <map>
6d713f5 @andrewrk handle structural equivalence correctly
authored
5 #include <vector>
b9cf6ab @thejoshwolfe started implementing an insensitive map. so far, it's still sensitive
thejoshwolfe authored
6
7 #include "utils.h"
8
9 template <class T>
6d713f5 @andrewrk handle structural equivalence correctly
authored
10 class OrderedInsensitiveMap {
b9cf6ab @thejoshwolfe started implementing an insensitive map. so far, it's still sensitive
thejoshwolfe authored
11 private:
12 std::map<std::string, T> m_map;
6d713f5 @andrewrk handle structural equivalence correctly
authored
13 std::vector<T> m_vector;
b9cf6ab @thejoshwolfe started implementing an insensitive map. so far, it's still sensitive
thejoshwolfe authored
14 public:
66ea104 @thejoshwolfe progress toward basic block construction
thejoshwolfe authored
15 OrderedInsensitiveMap() : m_map() {}
1214e91 @thejoshwolfe insensitive map is done. looks like it's not tested.
thejoshwolfe authored
16
6d713f5 @andrewrk handle structural equivalence correctly
authored
17 int count() { return m_vector.size(); }
3cc28d2 @andrewrk resolve class hierarchy corectly when calling function
authored
18 bool has_key(std::string x) { return m_map.count(Utils::to_lower(x)) > 0; }
eae318e @andrewrk generate 3 address code
authored
19 T get(std::string x) { return m_map[Utils::to_lower(x)]; }
20 T get(int i) { return m_vector[i]; }
20fa34c @thejoshwolfe progress on insensitive_map, but still no insensitivity
thejoshwolfe authored
21 void put(std::string key, T value);
b9cf6ab @thejoshwolfe started implementing an insensitive map. so far, it's still sensitive
thejoshwolfe authored
22 };
23
20fa34c @thejoshwolfe progress on insensitive_map, but still no insensitivity
thejoshwolfe authored
24 template <class T>
6d713f5 @andrewrk handle structural equivalence correctly
authored
25 void OrderedInsensitiveMap<T>::put(std::string key, T value) {
66ea104 @thejoshwolfe progress toward basic block construction
thejoshwolfe authored
26 m_map[Utils::to_lower(key)] = value;
6d713f5 @andrewrk handle structural equivalence correctly
authored
27 m_vector.push_back(value);
20fa34c @thejoshwolfe progress on insensitive_map, but still no insensitivity
thejoshwolfe authored
28 }
1214e91 @thejoshwolfe insensitive map is done. looks like it's not tested.
thejoshwolfe authored
29
6d713f5 @andrewrk handle structural equivalence correctly
authored
30 #endif
Something went wrong with that request. Please try again.