【发布时间】:2014-03-31 18:14:25
【问题描述】:
我正在开发一个 android 计划应用程序,但这没关系,问题是算法/方法,所以欢迎您编写 pusdo 代码来回答。
数据是这样的
Place
=============
Name
lat
lng
duration
isBookMark
type
Note: There are **only** two type: Shop , Park ,
duration is the time base on hour e.g. 1 => 1hour, 0.5 hour etc....
lat lng are the location unit
所以,我想根据以下标准生成一个随机地点列表:
1.) There are 2 duration limit
if short limit, then I need to get exactly 1 Park and some Shop , based on the hour 3 - 5 is given
if medium limit, I need to get exactly 2 Park and some Shop, based on the hour 6 -8 is given
if long limit, then I need to get exactly 3 Park and some Shop , based on the hour 9 - 11 is given
2. ) The user can select whether the bookmarked item is higher priority, so it may need to handle bookmark higher priority when select the item.
3. ) Also, the next place chosen must be the nearest place. You can assume there is already a `calcuateDistanceDiff()` function aviliable
那么,如何在上述情况下生成一个列表:
我试图简单地喜欢“硬编码”来一一处理持续时间限制,例如 先获得一个 Park,然后通过逐个检查优先级/距离来获得下一个,但应该有一些更明智的方法来创建更通用的“方法”来处理这个问题,以更好的性能和优雅。
感谢您的帮助
【问题讨论】:
标签: android performance algorithm