Data structure for linked list

Fxguy1 :

What is the best way to keep a list of items that is sortable and searchable? I want to have a list of medication-indications that I want to keep in order like this:

Medication --------- Indication

lisinopril --------- hypertension

amlodipine besylate --------- hypertension

amlodipine besylate --------- coronary artery disease (cad)

carvedilol --------- hypertension

ciprofloxacin --------- skin and skin structure infections

ciprofloxacin --------- bone and joint infections

No matter what order, amlodipine besylate HAS to match hypertension. I need to be able to sort alphabetically. Then I need to be able to get subsets. So I need to be able to pull the indications for say ciprofloxacin and lisinopril and then search to see if hypertension is in that resulting list.

How can I do this? I have it currently as two separate hash sets.

Harishma A :

Try using TreeMap

  • stores key-value pairs in sorted(ascending) order.
  • You can access the value using key
  • Key can be 'Medication'
  • Value can be 'Indication'

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=147596&siteId=1