Home > Back-end >  Delete an element array and ArrayList, what method overhead is small?
Delete an element array and ArrayList, what method overhead is small?

Time:01-27

In writing a more logical, want to delete an array or ArrayList elements has been compared, although don't know much about deleting the underlying implementation (such as displacement element), but know delete itself is overhead, if cost is larger than don't delete action

CodePudding user response:

ArrayList bottom is an array, if you need to do more complex operations, such as what you said is deleted overhead problem, you can use the ArrayList, you may not believe me, but you can not believe that Doug Lea, hope my answer will be helpful to you!

CodePudding user response:

refer to the original poster singing sound Amadues response:
in writing a more logical, want to delete the array or ArrayList elements has been compared, although don't know much about deleting the underlying implementation (such as displacement element), but know delete itself is overhead, if cost is larger than don't delete action


Only in the instance cases, the cost is possible,

CodePudding user response:

ArrayList of the underlying data structure is an array, the type of the array element for the Object type, all operations are based on the bottom of ArrayList array,
So you ask the question becomes a arrays and b delete an element in the array, what method, less overhead=what array to delete an element method overhead is small,
It involves the algorithm level, don't know much about,

CodePudding user response:

The ground floor of the ArrayList is one dimensional array, remove elements involved behind the reach of all nodes, delete node efficiency can be slow (under the premise of big data), personal ideas, if early know collection involves a large amount of data to delete or increase the operation with a LinkedList, if it involves a lot of search and modify the choice of the ArrayList, concrete depends on the scene, I am of the new, said bad, bosses do not spray me!!!!!!!
  • Related