我使用的Flex词典与时间戳ValueObjects存储为关键为每个对象。
由于时间戳,我想遍历从给定的时间标记键值启动的字典。
本文档讨论以下的字典迭代,但这种迭代从第一个键值对。
的(VAR键:在myDictionary对象)
{
跟踪(键,myDictionary [关键]);
}
解决方案
您可以只跳过所有项目之前,像这样的:
的(VAR键:在myDictionary对象)
{
如果(钥匙< searchKey)
继续;
跟踪(键,myDictionary [关键]);
}
不过,我的认为的该词典不保留任何排序顺序,因此需要与在字典中的项目的顺序是行不通的。
I am using Flex dictionary to store ValueObjects with Timestamp as the 'key' for each object.
Given a timestamp, I want to iterate over the dictionary starting from the given timestamp key value.
The Docs discuss the following for dictionary iteration, but this iterates from the first key-value pair.
for (var key:Object in myDictionary)
{
trace(key, myDictionary[key]);
}
解决方案
You could just skip all items before, like this:
for (var key:Object in myDictionary)
{
if ( key < searchKey )
continue;
trace(key, myDictionary[key]);
}
However, I believe that dictionaries do not maintain any sort order, so requiring an order with the items in the dictionary would not work.