包含标签 cpp articles

# Difference between map & unordered_map

目前有三个容器我不太了解其内部实现,打算通过 <c++ primer> 进行学习 map multimap unordered_map map map 是目前最简单的结构,实现的方法是 BST(binary search tree)。因此,其时间复杂度等都与 BST 相同,搜索,增加,删除基本时间都是 log(n)。 use map when 数据有序 需要按照有序的顺序获得元素 unordered_map unordered_map 则是通常所说的 hash table,哈希表,搜索,增加,删除都是以hash表为主,较好的情况是o(1),也就是hash函数可以较好的把元素分布到表中,如果 hash 函数比较糟糕,则每一次添加删除查找,都是完整遍历一个表。 use unordered_map when 对数据计数 只需要根据 key 访问 value 简单来讲,就是当你需要使用 vector 来计数的时候,可以用 unordered_map 来代替。 multimap multimap containers are generally slower than unordered_multimap containers to access individual elements by their key, but they allow the direct iteration on subsets based on their order. Multimaps are typically implemented as binary search trees.……

Continue reading

Ros Kinect Configure Note

This blog for my kinect-v2 ros configure. Environment Thinkpad P70 Ubuntu 14.04 indigo Reference to https://github.com/code-iai/iai_kinect2 Install Before start, make sure the cuda, cudnn has been configured correctly. First, you need to install libfreenect2. I recommend to use export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 in your .zshrc or .bashrc (more professional, in bash_profile or .zshenv). You will avoid some problems about library error. When installing libfreenect2, Use cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -DENABLE_CXX11=ON to generate Makeifle at build/……

Continue reading

C++学习必备

本文出自<svtter.github.io> (cplusplus)[http://www.cplusplus.com] 介绍三个头文件 在/usr/include/stdint.h中包含着各种关于C数据类型的定义,大小等。 unistd.h unix standard library header 这个函数库中包含read, write, gitpid等函数 stdlib.h standard library header ……

Continue reading

Linux-同步互斥

本文出自<svtter.github.io> 使用pthread实现经典问题:生产者消费者 关于semaphore的相关信息就不再贴出来了。 编译的时候记得-pthread选项。 运行结果 操作系统经典问题:哲学家就餐问题 mutex是c++11的新功能。记得添加C++11支持。(在运行结果中包含编译选项。) 运行结果 操作系统经典问题:读者写者问题 读者优先 使用了c++11的新特性thread 运行结果 由于可以同时阅读,所以读者reading输出可能出现少许问题。 写者优先 使rsem中只有一个读者在等待,保证了如果有写者,写者优先写 运行结果 基本上结果就是写者写完,才会有读者阅读 ……

Continue reading

Latest articles

Categories

Tags

Meta