Tools common method Colletions

Collections tools commonly used methods:

  1. Sequence

  2. Find and replace operations

  3. Synchronous control (not recommended, consider using a concurrent collection at JUC package needed thread-safe collection type

Sorting operation

 

void Reverse (List List) // inversion 
void shuffle (List List) // random ordering 
void Sort (List List) // Sort Ascending natural ordering 
void Sort (List List, Comparator C) // custom ordered from Comparator logic control sequencing 
void the swap (List List, int I, int J) // swap elements of two index positions 
void Rotate (List List, int Distance) // rotation. When the distance is positive, after List whole distance element to the front. When the distance is negative, the front distance elements integrally moved to the back of the list.

 

Find and replace operations

 

int binarySearch (List List, Object Key) // to List binary search, index returns, attention must be ordered List 
int max (Collection Coll) // according to the natural order of the elements, returns the largest element. Min analogy int (Collection Coll) 
int max (Coll Collection, Comparator C) // The custom ordering, returns the largest element, controlled by the collation Comparatator class. Min analogy int (Coll Collection, Comparator C) 
void Fill (List list, Object obj) // replace all the elements specified in the list with the specified elements. 
int Frequency (Collection c, Object O) // count the number of occurrences of elements 
int indexOfSubList (List list, List target) // statistical target index in the list of the first occurrence, or -1 if not found, the analogy int lastIndexOfSubList ( Source List, List target). 
boolean replaceAll (List list, Object oldVal, Object newVal), replace the old elements with new elements

Guess you like

Origin www.cnblogs.com/massionter/p/10991970.html