学习 LLVM(19) UniqueVector
2012-03-09 16:22
190 查看
位于 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(应避免使用).
UniqueVector 类产生一个从 1 开始的顺序值作为每个插入的唯一元素的 ID。模板参数 T 是数组元素类型。T 应该实现 ==, < 操作符。插入的项可以通过 [ID] 来访问。
这个类提供的对外方法不多。内部使用了昂贵的 Map, Vector 来实现底层存储,确实应该避免使用,或选择更合适的数据结构。
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(应避免使用).
UniqueVector 类产生一个从 1 开始的顺序值作为每个插入的唯一元素的 ID。模板参数 T 是数组元素类型。T 应该实现 ==, < 操作符。插入的项可以通过 [ID] 来访问。
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 来实现底层存储,确实应该避免使用,或选择更合适的数据结构。
相关文章推荐
- LLVM学习笔记(19)
- web前端学习日记19-------angularjs完成购物城
- [WorldWind学习]19.WebDownload
- CUBRID学习笔记 19 sql语句1
- Java集合源码学习(19)_Map接口的抽象实现AbstractMap
- 【MongoDB学习笔记19】MongoDB的游标和查询选项
- SPRING.NET 1.3.2 学习19--方法注入之查询方法注入
- CentOS学习19_centos6.5关闭transparent huge pages详细操作
- 19-spring学习-springMVC环境配置
- 学习 Python 编程的 19 个资源
- 黑马程序员_Java学习日记19_Socket编程1
- Hibernate学习19 -- 关联映射9 -- 继承映射3 -- 子类分别存储一张表
- 一步步学习SPD2010--第三章节--处理列表和库(19)----关键点
- java 核心学习(19)数组2
- 坚持学习WF(19):工作流线程
- 黑马程序员_JAVA 学习笔记19 WEB篇6
- hadoop2.7.2学习笔记19-ViewFs
- UNIX环境编程学习笔记(19)——进程管理之fork 函数的深入学习
- Linux设备驱动程序学习(19)-USB 驱动程序(四)
- [原创]java WEB学习笔记19:初识MVC 设计模式:查询,删除 练习(理解思想),小结 ,问题