0

I am trying to create a trigram model using LinkedHashMap> where Entry is the entry of last inputed bigram (whose structure is: LinkedHashMap

Now the problem is, being a map it does not store multiple keys (overwrites the existing key-value pair with new key-value pair for existing key).

I am not sure whether a multimap will be useful for this or not? If so, how?

3
  • I am not sure of your requirement but are you sure that a Map is the best fit for the job ? If I get what you try to do i'll try to approach it by creating a trigramm object containing three characters (or a bigramm and a char). Commented Feb 24, 2013 at 16:34
  • Issue resolved. Created a bigram obj, and used a LinkedHashMap<String,bigramobj>.... Commented Feb 24, 2013 at 20:25
  • Shouldn't a char be more appropriate than String ? Commented Feb 24, 2013 at 22:55

1 Answer 1

1

Every collections that implements Map interface keeps it's keys in Set implementation. Set can not keep multiple values.

Multimap is just a Map<Key, Collection<Value>>. It allows to keep multiple values under one key.

Read more about Maps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.