How to implement a collection (list, map?) of complicated strings in Java?
Posted
by Alex Cheng
on Stack Overflow
See other posts from Stack Overflow
or by Alex Cheng
Published on 2010-04-23T13:46:40Z
Indexed on
2010/04/23
14:33 UTC
Read the original article
Hit count: 226
Hi all. I'm new here.
Problem -- I have something like the following entries, 1000 of them:
args1=msg args2=flow args3=content args4=depth args6=within ==> args5=content
args1=msg args2=flow args3=content args4=depth args6=within args7=distance ==> args5=content
args1=msg args2=flow args3=content args6=within ==> args5=content
args1=msg args2=flow args3=content args6=within args7=distance ==> args5=content
args1=msg args2=flow args3=flow ==> args4=flowbits
args1=msg args2=flow args3=flow args5=content ==> args4=flowbits
args1=msg args2=flow args3=flow args6=depth ==> args4=flowbits
args1=msg args2=flow args3=flow args6=depth ==> args5=content
args1=msg args2=flow args4=depth ==> args3=content
args1=msg args2=flow args4=depth args5=content ==> args3=content
args1=msg args2=flow args4=depth args5=content args6=within ==> args3=content
args1=msg args2=flow args4=depth args5=content args6=within args7=distance ==> args3=content
I'm doing some sort of suggestion method. Say, args1=msg args2=flow args3=flow ==> args4=flowbits
If the sentence contains msg, flow, and another flow, then I should return the suggestion of flowbits.
How can I go around doing it? I know I should scan (whenever a character is pressed on the textarea) a list or array for a match and return the result, but, 1000 entries, how should I implement it?
I'm thinking of HashMap, but can I do something like this?
<"msg,flow,flow","flowbits">
Also, in a sentence the arguments might not be in order, so assuming that it's flow,flow,msg then I can't match anything in the HashMap as the key is "msg,flow,flow".
What should I do in this case? Please help. Thanks a million!
© Stack Overflow or respective owner