*
The moose likes OO, Patterns, UML and Refactoring and the fly likes How to build smart key / value structure from input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "How to build smart key / value structure from input " Watch "How to build smart key / value structure from input " New topic
Author

How to build smart key / value structure from input

Meir Yan
Ranch Hand

Joined: Apr 27, 2006
Posts: 597
Hello
I have this scenario that im trying to find the best algorithm to implement it .
Im getting as input array that each element contains key value object


Im my application I need to hold some kind of table structure in memory (fetched from db ) .
Each row contains list of values and one more column that represent the name of all the values in that raw.
For example:

PKG_TYPE | CHECKED | SUSPEND | FREE
pkgFree , 1,0,0
pkgPay , 1,1,1
pkgDemo,0,1,1
all the numbers in this example are primary keys so when im getting the input array
I will get :
inputArr [0]=>checked,1
inputArr [1]=>suspend,0
inputArr [3]=>free,0

and according to these values I will get the service name in this case pkgFree.

My question is what is the best way to implement the in memory table ( it will contains like 300-500 raws )
And also how to perform this patch from this table when input is arriving.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
You might concatenate the key parts into one String and use it as a HashMap key:

If the values are always 0 and 1, you can read them like a bitmap and convert them to ints:

Either of those sound useful?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to build smart key / value structure from input
 
Similar Threads
Check Box with Jsp:How-To
Checkbox value not being passed to bean.
Sun Cirtification
using ajax and struts iterate tags
Getting objects value in a map