How to iterate over a Flex dictionary, starting with a given key?

I use the Flex dictionary to store ValueObjects with a timestamp as a "key" for each object.

Given the timestamp, I want to iterate over the dictionary, starting with the given value of the time key.

The docs discuss the following for iteration of a dictionary, but this is an iteration of the first key-value pair.

for (var key:Object in myDictionary)
{
    trace(key, myDictionary[key]);
}
+3
source share
1 answer

You could just skip all the elements earlier, for example:

for (var key:Object in myDictionary)
{
    if ( key < searchKey )
        continue;

    trace(key, myDictionary[key]);
}

However, I believe that dictionaries do not support sort order, so the order requirement with elements in the dictionary will not work.

+7
source

All Articles