Class DictPtr


			
class DictPtr : public ObjectPtr
Programmer: Ryan Davis

Description:

I provide an extension of ObjectPtr's services to include named accessors and utilities for dictionaries.

Public Methods:

static ObjectPtr create ();
I am create. I act as a "factory method" for creating new dictionary objects.

static DictPtr convert (const ObjectPtr & obj);
I convert obj to a valid AssocPtr or gNil if obj wasn't a dictionary.

DictPtr (const ObjectPtr & pointee);
This is the constructor. It has a default value of gNil, so it can be used as the generic constructor as well. This constructor creates a Object pointer that points to the address passed in through .

Boolean indexAt (const String & key, UInteger & index);


Boolean indexAt (const ObjectPtr & key, UInteger & index);


Boolean indexAt (const SymbolPtr & key, UInteger & index);
I find and set the index of the association in the dictionary matching key, and return true. If I can't find the key, then I return false.

AssocPtr & assocAt (const String & key);


AssocPtr & assocAt (const ObjectPtr & key);


AssocPtr & assocAt (const SymbolPtr & key);
I find the association in the dictionary matching key, or return gNil...

ObjectPtr & at (const String & key);


ObjectPtr & at (const ObjectPtr & key);


ObjectPtr & at (const SymbolPtr & key);
A dictionary is internally defined as an array, so we can treat this thing like an array of associations. All we do is search over the array for the key, if it is not found, we return nil.

void atPut (const String & key, const ObjectPtr & value);


void atPut (const ObjectPtr & key, const ObjectPtr & value);


void atPut (const SymbolPtr & key, const ObjectPtr & value);
We use assocAt() to find the key-entry we are looking for. If assocAt() returns nil, then we add a new association to the end of the array.

ArrayPtr keys ();


ArrayPtr values ();
Guess... I am the method used to test the validity of the methods in DictPtr. Services

Protected Methods:

static ObjectPtr create (const UInteger initialSize);
I am create. I act as a "factory method" for creating new dictionary objects.

static ClassPtr & klassPtr ();


void grow ();
I grow the array by one entry. I should ONLY be used by atPut().

Protected Members: