开发者

How to iterate over a Flex dictionary starting from a given key?

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-v开发者_如何学编程alue 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜