Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 14 in printed book and digital formats -- plus a one-year subscription so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

PDF:

Beginner's Corner

A Two-Way Dictionary

Extending the Dictionary

Issue: 9.5 (July/August 2011)
Author: Marc Zeedar editor-at-rbdeveloper.com
Article Description: No description available.
Article Length (in bytes): 13,384
Starting Page Number: 63
RBD Number: 9509
Resource File(s):

Download Icon 9509.zip Updated: Tuesday, July 5, 2011 at 11:18 AM

Related Link(s): None
Known Limitations: None

Excerpt of article text...

I've written in the past about how wonderful dictionary objects are for data storage. I use them all the time. I like them better than arrays because they're faster for data retrieval and because they are based upon the variant datatype, you can store anything inside them (even other dictionaries). But dictionaries aren't the end-all and sometimes you can extend them or enhance them to create new objects that are even more powerful.

For example, how about a SortedDictionary? It always keeps itself in sort order even as you add new contents. (I'll leave you to write that one.)

You can also create dictionary variations that are optimized for the specific kind of data you're working with. That's what we're going to do today, but in a generic way that allows us to reuse this new class in all sorts of programs.

I'm talking about a Two-Way Dictionary. A normal dictionary is a key-value setup: that means you need the key to find its value. For most situations that's fine. But what if you had the value but not the key? Wouldn't it be nice to pass either the key or the value and get back its opposite?

...End of Excerpt. Please purchase the magazine to read the full article.

Article copyrighted by REALbasic Developer magazine. All rights reserved.


 


|

 


Weblog Commenting and Trackback by HaloScan.com