isnan和hash_map使用问题解决方法
来源:互联网 发布:淘宝c店排名 编辑:程序博客网 时间:2024/05/16 07:03
by wangsh 2011-11-15
isnan问题:在GIS开发中,我们计算两点之间距离之后,需要判断距离是否isnan(
double dist = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1))*6371.0;)。
并不是所有的编译器都有isnan,vs2008中没有isnan,在合适的地方加入:
inline bool isnan(double v)
{
return v!=v;
}
这时候完整代码段为:
/* Return distance in km */
double fast_distance_rad(double lat1, double lon1, double lat2, double lon2)
{
double dist = acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon2-lon1))*6371.0;
if(isnan(dist))
{
dist = 0;
}
return dist;
}
hash_map的使用:hash_map基于hash table,其最大优点是降低数据存储与查找消耗时间,可近似为常数时间;而代价仅是消耗较多内存。而在当前可利用内存越来越多的情况下,用空间换时间的做法是值得的。(具体参考1和2)
使用hash_map例:
#include <hash_map>
using namespace std;
using namespace stdext;
typedef stdext::hash_map<int, GPSCoordinate>::value_type hashGPS;
参考资料
1. Blog http://www.cppblog.com/woaidongmao/archive/2008/10/15/64014.html
2. 介绍 http://blog.csdn.net/ztj111/article/details/1895200
3. 性能比较 http://hi.baidu.com/lujunqianglw/blog/item/9f7fbc549233cd063b293582.html
- isnan和hash_map使用问题解决方法
- JavaScript : isNaN()和Number.isNan()
- hash_map和unordered_map的使用
- hash_map/unordered_map原理和使用
- 使用JS判断是否数字和小数点组合的数字的两中方法比较-isNaN和逐判断
- jQuery的isNaN和isNumeric方法源码分析
- JavaScript—特殊数值:NaN和isNaN()方法
- JavaScript isNaN() 方法 用法
- Float 的isNan 方法
- JavaScript中的isNaN()方法
- Float.isNaN() 方法
- isnan 和 isinf
- hash_map 使用
- vc++2005 和 g++中使用hash_map
- 使用map和hash_map的效率问题
- hash_map/unordered_map原理和使用整理
- isNaN()
- isNaN
- 制作并使用静态类库(Static Library)详细教程
- 批处理常用命令及用法大全
- 通过SQL 2005 系统表监控 SQL Server 的运行状况
- linux中的IP负载均衡实现原理
- keil新建工程及编译报错——invalid redeclaration of type name "s32" 的解决
- isnan和hash_map使用问题解决方法
- Java设计模式-----代理模式
- JDK1.6字符串拼接自动生成StringBuilder
- java的几种对象解释
- 个人通讯录(一)开发数据库的辅助类
- 如何抓取QQ2010的聊天框
- VIM中的正则表达式
- js 定时刷新页面
- 模仿酷狗7(Kugou7)界面源码