Re: hashtable - select by wilecard... is it doable?
- From: Dan Andrews <danharrisandrews@xxxxxxxxx>
- Date: Wed, 27 Sep 2006 18:14:56 -0600
tak wrote:
Hi,
What is a data structure out there, that you can select by wilecard,
and also have fast retrievals?
like, if i have 4 keys, JOHN, JONATHAN, JOAN, TOM., and I want to do a
getKey by, "JO*", and that would return the values for the one that
matches JO* as either array, set, collection..etc...
thanks,
T
If you are only concerned about matching the first few characters (starts with JO) then would a TreeSet<String> (that I refer to a treeSet below) work?
SortedSet<String> tailSet = treeSet.tailSet("JO");
TreeSet<String> matchingSet = new TreeSet<String>();
for (String s : tailSet) {
if (!s.startsWith("JO")) {
break;
}
matchingSet.add(s);
}
return matchingSet;
Just and idea and not sure if it is what you need.
Cheers,
Dan Andrews
- - - - - - - - - - - - - - - - - - - - - - - - -
Ansir Development Limited http://www.ansir.ca
- - - - - - - - - - - - - - - - - - - - - - - - -
.
- Follow-Ups:
- Re: hashtable - select by wilecard... is it doable?
- From: Hendrik Maryns
- Re: hashtable - select by wilecard... is it doable?
- References:
- Prev by Date: Re: need Help in reflect an RMI object
- Next by Date: Re: End of String
- Previous by thread: hashtable - select by wilecard... is it doable?
- Next by thread: Re: hashtable - select by wilecard... is it doable?
- Index(es):
Relevant Pages
|
|