BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 10-20-2009, 02:10 PM   #1 (permalink)
Thumbs Must Hurt
Join Date: Aug 2009
Model: Tour
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:

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.


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.

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 02:22 PM.
Old 10-20-2009, 04:47 PM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts

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.
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
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.