Custom Wrapper Class for Dictionary component – Flex

I was developing a Flex module earlier yesterday and somehow felt the need of an efficient data structure for look-up purpose. Array and ArrayCollection are just not good enough and the default implementation of Dictionary as part of Flex API is a no-brainer. So, I decided to create a wrapper functionality similar to the Dictionary Class available in languages such as C# and Java (HashTable). This version of Dictionary is actually a hybrid between a set (uniqueness) and dictionary (fast lookups) based on my requirements.

So far, I have implemented the following functionality >>

  • insertKey(key : Object, value : Object)
  • getSize()
  • removeKey(key : Object)
  • clear()
  • containsKey(key : Object)
  • containsValue(value : Object)
  • toString()
  • getKeys()
  • getValues()

Source code is available here >> MyDictionary.as MDIllegalObjectException.as

(Replace the “.as_.txt” extension to “.as” before using the file)

Feel free to modify the source code and if any bugs are found, please do comment back to the post as it will be helpful to others.

A sample demo testing the MyDictionary Class can be seen here >> Test3.mxml

(Replace the “.mxml_.txt” extension to “.mxml” before using the file)

leave your comment