1

I am very much new in java (but not to programming). I have to design a data structure, as indicated below. The columns are (dynamic and) identified by id (e.g. 77, 55, 67 etc). For each column, I can have dynamic entries in rows, but the entry "must be" following the order of insertion. Means when we retrieve, they should be output in the same order of insertion. After N entries, I want to delete the oldest entry, to control the list size.

MY QUESTION: What data structure (e.g. HashMap, ArrayList, Set etc) for columns and rows I should use for my problem in java.

data

2 Answers 2

3

It looks like a map of rows, and a row looks like a Map... meaning:

Map<Integer, LinkedHashMap<Integer, Double>> collection = new HashMap<Integer, LinkedHashMap<Integer, Double>>();

the LinkedHashMap will retain the order elements (LinkedHashMap is ordered, TreeMap is sorted, HashMap is none).

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

Comments

2

It looks like you're looking for a Queue

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.