Article Preview
Buy Now
| Print: | |
| PDF: |
Beginner's Corner
Basic Data Structures, Part II
Discovering the Dictionary
Issue: 4.5 (May/June 2006)
Author: Marc Zeedar
editor-at-rbdeveloper.com
Article Description: No description available.
Article Length (in bytes): 9,154
Starting Page Number: 34
RBD Number: 4511
Resource File(s):
4511.sit Updated: Monday, May 15, 2006 at 4:52 PM
4511.zip Updated: Monday, May 15, 2006 at 4:52 PM
Related Link(s): None
Known Limitations: None
Excerpt of article text...
In the previous issue I introduced the concept of data structures and demonstrated several kinds -- a string, an array of string, and custom classes -- and explained the advantages and disadvantages of each. In today's lesson we'll continue to explore kinds of data structures, beginning with an exploration of RB's dictionary object.
The Dictionary Object
One of REALbasic's best-kept secrets is its awesome dictionary class. A dictionary is a bit of a weird beast and as such scares off many beginners, but it is one of the best data structures available.
What makes a dictionary so powerful is that it features automatic indexing. An index allows for extremely fast lookups. Even if the number of records is huge, lookups are almost instantaneous (see the "How Does Indexing Speed Searching?" sidebar for details about how indexing works).
To use a dictionary, you store data in key-data pairs. You have the actual data you want to save along with a unique key. The key is like the index of an array in the sense that you need to know an item's key in order to retrieve it from the dictionary. Most important, the key must be unique: you can only save one piece of data per key. (If you attempt to save a second piece of data using the same key, the original data will be lost and replaced by the second data.)
...End of Excerpt. Please purchase the magazine to read the full article.
Article copyrighted by REALbasic Developer magazine. All rights reserved.
|








