位于 llvm/include/llvm/[[ADT]]/UniqueVector.h数组
UniqueVector is similar to SetVector, but it retains(容纳) a unique ID for each element inserted into the set. It internally contains a map and a vector(内部由 map 和 vector 构成), and it assigns a unique ID for each value inserted into the set.数据结构
UniqueVector is very expensive(昂贵的): its cost is the sum of the cost of maintaining both the map and vector, it has high complexity, high constant factors, and produces a lot of malloc traffic. It should be avoided(应避免使用).ide
UniqueVector 类产生一个从 1 开始的顺序值做为每一个插入的惟一元素的 ID。模板参数 T 是数组元素类型。T 应该实现 ==, < 操做符。插入的项能够经过 [ID] 来访问。code
template <T> class UniqueVector { std::map<T, unsigned_ID> Map; // 从 entry 映射到 ID std::vector<T> Vector; // 从 ID 映射到 entry insert(T&) // 新增一个 entry,若是存在则返回已存在项的 ID idFor(T&) // 根据 entry 在 Map 中找到其对应的 ID,返回 0 表示没找到 [] // 数组访问符,经过 ID 访问 entry size(), empty(), reset() 通常容器方法。 }
这个类提供的对外方法很少。内部使用了昂贵的 Map, Vector 来实现底层存储,确实应该避免使用,或选择更合适的数据结构。
element