Merge pull request #506 from andrewcsmith/patch-2
[supercollider.git] / external_libraries / yaml-cpp-0.3.0 / include / yaml-cpp / contrib / anchordict.h
blobe483dc4b5d9023417ec776b550b79be483984137
1 #ifndef ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
5 #pragma once
6 #endif
8 #include <vector>
10 #include "../anchor.h"
12 namespace YAML
14 /// AnchorDict
15 /// . An object that stores and retrieves values correlating to anchor_t
16 /// values.
17 /// . Efficient implementation that can make assumptions about how anchor_t
18 /// values are assigned by the Parser class.
19 template <class T>
20 class AnchorDict
22 public:
23 void Register(anchor_t anchor, T value)
25 if (anchor > m_data.size())
27 m_data.resize(anchor);
29 m_data[anchor - 1] = value;
32 T Get(anchor_t anchor) const
34 return m_data[anchor - 1];
37 private:
38 std::vector<T> m_data;
42 #endif // ANCHORDICT_H_62B23520_7C8E_11DE_8A39_0800200C9A66