Tag Archives: Dictionary

Prefix Tree

Creating a prefix tree is quite easy in Python! root = {} def addToTree(node, word=()): if not word: return addToTree(node.setdefault(word[0], {}), word[1: ]) def main(): for word in (‘batman’, ‘bane’, ‘bale’,): addToTree(root, word) print root Output: {‘b’: { ‘a’: { ‘l’: { ‘e’: {} }, ‘n’: { ‘e’: {} }, ‘t’: { ‘m’: { ‘a’: […]

0  

Create your own basic In-Memory Cache

In one of my recent projects, there was a requirement to cache data for a stipulated period of time (say 3 minutes) in order to prevent frequent database look-ups. Obviously, improving the efficiency of the system was also another requirement. 😉 Via illustrations as shown below, I have made a basic flowchart about the different […]

0  

Custom Wrapper Class for Dictionary component – Flex {UPDATED}

Added some new functionality and plugged possible bugs. New functions incorporated: function insertKeyValue(keyValueCombo:Object):void >>Argument passed in is used as both Key and Value function insertArray(arr:Array):void >>Takes an Array object as argument and inserts each Array element in the MyDictionary Object function clone():MyDictionary >>Performs a deep copy function getValue(key : Object):Object >>Returns the corresponding value for the […]

0  

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 […]

0