Home > Back-end >  ArrayList TreeSet
ArrayList TreeSet

Time:09-21

ArrayList TreeSet both are ordered, what is the difference between the two of them the orderly?

CodePudding user response:

Arraylist in order?

CodePudding user response:

https://blog.csdn.net/forever428/article/details/83065541

CodePudding user response:

It involves the use of the data structure of bottom is different, the ArrayList array is used the TreeSet is a tree, to understand in detail, can be to search in this way

CodePudding user response:

Order refers to the deposit and remove the result is same, TreeSet just realized the automatic sorting, so lead to finally the results you see are ordered, when you use a custom object type, you need to realize the Comparator to sort, while the ArrayList is an ordered array to realize the underlying

CodePudding user response:

Look at your order?
If consistent access sequence, then only the arraylist can guarantee, treeset is does not guarantee that an orderly, said all the reasons (LS)
If refers to the data storage size order and orderly, arraylist is done, through setting comparetor treeset can achieve automatic sorting,

CodePudding user response:

ArrayList orderly, refers to the element into the operation sequence,
TreeSet orderly, referring to the volume into the element can be compared, and then, according to the size of the order,
  • Related