How do I get all the keys in a map container?

I am currently switching from an array to a map container in one of my verse classes to optimize processing. Is there a way to get all the keys that a container currently uses? Or a way to grab a random key?

All the main pages with examples and methods for verse map containers have been removed in the past few months from the website and the Book of Verse is not very descriptive on the map methods that are available.

Hi, as far as I know you would have to use an extension method.

(Map:[t1]t2 where t1:subtype(comparable), t2:type).GetKeys()<transacts>:[]t1=
    var Keys : []t1 = array{}
    for(Key->Value : Map):
        set Keys += array { Key }
    return Keys

using { /Verse.org/Random }
(Input:[]t where t:type).GetRandom()<decides><transacts>:t=
    var RandomValue : ?t = false
    RandomIndex := GetRandomInt(0, Input.Length - 1)
    if(Value := Input[RandomIndex]):
        set RandomValue = option { Value } 
    RandomValue?

Something like this, and then you could get a random key checking the length of the array. This can fail, so we use the decides.

Thanks, I guess there isn’t a built in function. I ended up with the following after asking the developer assistant and altering it to be more modular that I can put in my utility module. I reused the GetRandomInt(0, Map.Length -1) from the original code I had for arrays

GetKeys<public>(TheMap:[k]t where t:type, k:subtype(comparable))<transacts>:[]k =
        var Keys: []k = array{}
        for (Key -> Value : TheMap):
            set Keys += array{Key}
        Keys