[자바] ArrayList와 Queue의 remove() 함수에 대해
자바에서 ArrayList, Queue, PriorityQueue는 꽤나 닮은 점이 많습니다.
그 중 하나는 모두 remove() 함수를 가지고 있다는 것입니다.
좀 더 정확히 말하면 아래의 함수를 가지고 있습니다.
boolean | remove(Object o)
Removes the first occurrence of the specified element from this list, if it is present. |
원소로 Object를 가지는 경우 처음부터 확인하면서 발견되는 Object를 삭제하는 함수입니다.
그러나 아래의 함수는 ArrayList에만 있습니다.
E | remove(int index)
Removes the element at the specified position in this list. |
ArrayList에서 remove함수에 int index를 주면 index위치에 있는 원소를 삭제합니다.
참고
docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
ArrayList (Java Platform SE 7 )
Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is
docs.oracle.com
docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html
PriorityQueue (Java Platform SE 7 )
An unbounded priority queue based on a priority heap. The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used. A priority queue does
docs.oracle.com
댓글 영역