BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 10-20-2009, 03:10 PM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Aug 2009
Model: Tour
PIN: N/A
Carrier: Verizon
Posts: 84
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Hashtable of Custom Objects--Search through the Hashtable for Objects with Spec Value

Please Login to Remove!

I have a class defined:

Code:
class Transaction{
  private int _id;
  private int _parent;
  private int _account;
  private double _amount;

  //I'm not going to show them all here for space reasons, but
  //I do have all the "setters", "getters" & constructors etc that I need
}
Then I have a hashtable that has all the Transaction objects. I'm trying to figure out a way to search through the Hashtable and return all the transactions with "account" = X (X could be any integer).

Could someone offer some advice as to how I can accomplish this? or if you have a better solution, I'm open to that as well. This app is still in its infancy.

TIA!

P.S. I meant to mention that I originally developed this setup based on my experiences with PHP and MySQL. But it dawned on me last night that I don't have the same search capabiites here. And no--I don't want to connect to the MySQL server to do the searches.
__________________
Don

Handspring Visor -> Handspring Visor Deluxe -> Palm Treo 650 on VZW -> Palm Treo 700p on VZW -> Blackberry Tour 9360 on VZW

Last edited by doni49 : 10-20-2009 at 03:22 PM.
Offline  
Old 10-20-2009, 05:47 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

I guess the quick answer is to get an Enumeration of the hashtable, and search through the table looking for you values.

If the table is very large, you might want to look at using SimpleSortingVector to hold the key values, and use this to perform a binary search.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.