Samstag, 24. September 2016

iterating through the keySet (of a HashMap)


declare java.util.HashMap hm!
hm! = new java.util.HashMap()
hm!.put("myKey1",100)
hm!.put("myKey2",200)


declare BBjVector v!
v!=new BBjVector(java.util.Arrays.asList(hm!.keySet().toArray()))
v!=new BBjVector(java.util.Arrays.asList(hm!.values().toArray()))
java.util.Collections.sort(v!); REM sorting vector 
x = v!.contains(IdOrValue$)
i = v!.indexOf(IdOrValue$)

declare java.util.Set ks!
ks! = hm!.keySet()
i! = ks!.iterator()
while i!.hasNext()
    key!=i!.next()
    value=hm!.get(key!)
    ?">>"+key!+"="+str(value)+"<<"
wend

firstValue=num(java.util.Arrays.asList(hm!.keySet().toArray()).get(0))

Benefit from the best Windows Desktop app in the world and use Strokey.Net!