Collections Utility Class Flashcards
Looks for the key in List. If found, returns a value >= 0; otherwise returns a negative value. It has an overloaded version that also takes a comparator object.
int binarySearch(List, key)
Copies all elements from src List to dst List.
void copy(dest, src)
Fills the whole List with the value obj.
void fill(List, obj)
Returns the max element in the list. Has an overloaded version that takes a comparator.
T max(Collection)
Returns the min element in the list. Has an overloaded version that takes a comparator.
T min(Collection)
Replaces all occurences of oldVal with newVal in the list.
boolean replaceAll(List, oldVal, newVal)
Reverses all the elements in the given list.
void reverse(List)
Rotates the list given by the value distance.
void rotate(List, int distance)
Shuffles the elements in the list randomly.
void shuffle(List)
Sorts the list in its natural order. Has an overloaded version that also takes a comparator object.
void sort(List)
Swaps the elements in the positions i and j in the list.
void swap(List, int i, int j)