Dictionary(Object)

Dictionary is a collection of key and value pairs. Dictionary values can be referenced with an indexer syntax [“key”]. Note, Dictionary is not as robust as C#’s dictionary but they serve similar purposes. The ObservableDictionary provides events for when key/value pairs are added, removed or cleared.

Constructors

Dictionary() Creates a new dictionary.

Fields

Count Number Number of key value pairs in the dictionary
Keys Array Collection of keys in the dictionary.
Type Type Returns Type.Dictionary

 

Events

OnAdd ArrayEventArgs Fired when a key/value pair is added to the dictionary
OnClear ArrayEventArgs Fired when Clear() is called from the dictionary.
OnRemove ArrayEventArgs Fired when a key is removed from the dictionary.

Functions

Add(String key, Object value) undefined Adds a key/value pair with the provided key and value.
Add(Number key, Object value) undefined Adds a key/value pair with the provided key and value.
Clear() undefined Clears the dictionary of all key/value pairs.
ContainsKey(String key) Boolean Returns whether the dictionary contains the provided key.
ContainsKey(Number key) Boolean Returns whether the dictionary contains the provided key.
ContainsValue(Object obj) Boolean Returns whether the dictionary contains the value.
Copy() Dictionary Returns a copy of the dictionary.
ForEach(Function func) Dictionary Loops through all key/value pairs and calls the provided function passing in a single parameter of the type IterationEventArgs. "this" will refer to the current key/value pair of the type KeyValuePair.
GetValue(String key) Object Returns the value associated with the provided key.
GetValue(Number key) Object Returns the value associated with the provided key.
Remove(String key) undefined Removes the key and the value associated with the key.
Remove(Number key) undefined Removes the key and the value associated with the key.
SetValue(String key, Object value) undefined Sets the existing key the provided value, if it exists, otherwise a new key/value pair is added.
SetValue(Number key, Object value) undefined Sets the existing key the provided value, if it exists, otherwise a new key/value pair is added.
Values() Array Returns an array of all existing values in the dictionary.

Last edited Feb 4, 2011 at 2:15 AM by dahrkdaiz, version 1

Comments

No comments yet.