Something similar to Set<String, Set<String>>
in Java?
The VBScript Dictionary object provides an item indexing facility. Dictionaries are part of Microsoft's Script Runtime Library. The Dictionary object is used to hold a set of data values in the form of (key, item) pairs. A dictionary is sometimes called an associative array because it associates a key with an item.
A dictionary object in UFT is very much similar to an array. Unlike an array index, there is a unique key associated with every item of a dictionary object. Using the Key name, the associated value can be called anywhere in the script.
Exists Method Exist Method helps the user to check whether or not the Key Value pair exists.
A Set is an unordered collection of unique elements. Many Set implementations are based on hash tables (possibly of key-value pairs). VBScript has a Dictionary class -
Dim dicParent : Set dicParent = CreateObject("Scripting.Dictionary")
You can't add the same key twice, so the keys of a VBScript Dictionary represent/model a Set (the Set is ordered (by insertion), however). Nothing keeps you from putting (other) Dictionaries into the values:
>> Dim dicParent : Set dicParent = CreateObject("Scripting.Dictionary")
>> dicParent.Add "Fst", CreateObject("Scripting.Dictionary")
>> dicParent("Fst").Add "Snd", "child of parent"
>> WScript.Echo dicParent("Fst")("Snd")
>>
child of parent
In VBScript (and theory), you can even use objects as keys (not only strings as in other languages):
>> Dim dicParent : Set dicParent = CreateObject("Scripting.Dictionary")
>> Dim dicChild : Set dicChild = CreateObject("Scripting.Dictionary")
>> dicParent(dicChild) = "child of parent"
>> WScript.Echo dicParent(dicChild)
>>
child of parent
Your practical mileage may vary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With