Re: hashtable - select by wilecard... is it doable?
- From: Hendrik Maryns <hendrik_maryns@xxxxxxxxxxxxx>
- Date: Thu, 28 Sep 2006 10:10:01 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Dan Andrews schreef:
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.
He probably needs a TreeMap<String,Something>, but the principle remains
the same.
H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFFG4NZe+7xMGD3itQRAns3AJ0ba/FB9Wbis3hk8KkWJKSeaIXg5wCeKf0Z
rWHF0ck07J84YLkd9hRSoy4=
=xeVU
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: hashtable - select by wilecard... is it doable?
- From: Patricia Shanahan
- Re: hashtable - select by wilecard... is it doable?
- References:
- hashtable - select by wilecard... is it doable?
- From: tak
- Re: hashtable - select by wilecard... is it doable?
- From: Dan Andrews
- hashtable - select by wilecard... is it doable?
- Prev by Date: Creating beans from database tables
- Next by Date: Re: binary insertion
- Previous by thread: Re: hashtable - select by wilecard... is it doable?
- Next by thread: Re: hashtable - select by wilecard... is it doable?
- Index(es):
Relevant Pages
|
|