开发者

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

开发者 https://www.devze.com 2023-02-15 17:00 出处:网络
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.

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

精彩评论

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