1.从建数据库表和基本原理说起 A too big topic to discuss here.2.另一个问题是,我做一个船避碰的模型,要求没两只船在一定范围外,比如两两大于100米,怎么遍历每只船只? The problem becomes "find the shortest distance between boats", which can be done in O(n*log n). You may refer to my implementation(64th) here:[URL=http://topic.csdn.net/u/20080527/15/4993ada8-99b2-41e8-941c-1aee649971a6.html]我也出一个好玩的算法贴:扔把瓜子在桌子上,找出最近的两个,C#实现[URL]
无限级的树的表结构 我们原来设计的有个小细节还可以,增加个冗余字段,记录节点的位置 比如1_2,1_1_2,最后数字是节点的ID,前面依次是父节点ID,这样的好处是可以通过 like 语句查询出父节点的所有子节点 另外,sql server 2005 有个通用表表达式,CTE(Common Table Expression),可以实现递归查询
foreach(ship sp1 in ships) { foreach(ship sp2 in ships) { if(sp1!=sp2) { distance=abs(sp1.position-sp2.position); ... } } }
A too big topic to discuss here.2.另一个问题是,我做一个船避碰的模型,要求没两只船在一定范围外,比如两两大于100米,怎么遍历每只船只?
The problem becomes "find the shortest distance between boats", which can be done in O(n*log n).
You may refer to my implementation(64th) here:[URL=http://topic.csdn.net/u/20080527/15/4993ada8-99b2-41e8-941c-1aee649971a6.html]我也出一个好玩的算法贴:扔把瓜子在桌子上,找出最近的两个,C#实现[URL]
比如1_2,1_1_2,最后数字是节点的ID,前面依次是父节点ID,这样的好处是可以通过 like 语句查询出父节点的所有子节点
另外,sql server 2005 有个通用表表达式,CTE(Common Table Expression),可以实现递归查询
{
foreach(ship sp2 in ships)
{
if(sp1!=sp2)
{
distance=abs(sp1.position-sp2.position);
...
}
}
}