๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ–‹๏ธ ์ž๋ฃŒ๊ตฌ์กฐ์™€ ์•Œ๊ณ ๋ฆฌ์ฆ˜/์ฝ”๋”ฉํ…Œ์ŠคํŠธ

[๋ฉ”์„œ๋“œ] ArrayList ํด๋ž˜์Šค ๋ฉ”์„œ๋“œ

by OR15A 2023. 11. 21.

2023.11.14 - [๐Ÿ–ฅ๏ธ ๋ฐฑ์—”๋“œ/Java] - [ch.11] ์ปฌ๋ ‰์…˜ ํ”„๋ ˆ์ž„์›Œํฌ ๊ฐœ์š” ๋ฐ List

 

void trimToSize(): ArrayList์˜ ์šฉ๋Ÿ‰์„ ํ˜„์žฌ ๋ฆฌ์ŠคํŠธ ํฌ๊ธฐ์— ๋งž๊ฒŒ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค. ๋ถˆํ•„์š”ํ•œ ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ์„ ์ค„์ด๋Š” ๋ฐ ์œ ์šฉํ•ฉ๋‹ˆ๋‹ค.

void ensureCapacity(int minCapacity): ArrayList์˜ ์ตœ์†Œ ์šฉ๋Ÿ‰์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ํ•„์š”์‹œ ๋‚ด๋ถ€ ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ํ™•์žฅํ•˜์—ฌ ์ง€์ •๋œ ์šฉ๋Ÿ‰์„ ์ˆ˜์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

Object[] grow(int minCapacity): ๋ฆฌ์ŠคํŠธ์˜ ์šฉ๋Ÿ‰์„ ํ™•์žฅํ•ฉ๋‹ˆ๋‹ค. ์ฃผ๋กœ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋ฉฐ, ์ƒˆ๋กœ์šด ์šฉ๋Ÿ‰์œผ๋กœ ๋ฐฐ์—ด์„ ํ™•์žฅํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

int newCapacity(int minCapacity): ์ƒˆ๋กœ์šด ์šฉ๋Ÿ‰์„ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค. ์ด๊ฒƒ๋„ ์ฃผ๋กœ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

int hugeCapacity(int minCapacity): ๋งค์šฐ ํฐ ์šฉ๋Ÿ‰์˜ ๋ฆฌ์ŠคํŠธ๋ฅผ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

int size(): ๋ฆฌ์ŠคํŠธ์— ์ €์žฅ๋œ ์š”์†Œ์˜ ๊ฐœ์ˆ˜๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

boolean isEmpty(): ๋ฆฌ์ŠคํŠธ๊ฐ€ ๋น„์–ด์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

boolean contains(Object o): ๋ฆฌ์ŠคํŠธ๊ฐ€ ํŠน์ • ์š”์†Œ๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š”์ง€ ์—ฌ๋ถ€๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

int indexOf(Object o): ๋ฆฌ์ŠคํŠธ์—์„œ ํŠน์ • ์š”์†Œ๊ฐ€ ์ฒ˜์Œ์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

int indexOfRange(Object o, int start, int end): ์ง€์ •๋œ ๋ฒ”์œ„ ๋‚ด์—์„œ ํŠน์ • ์š”์†Œ๊ฐ€ ์ฒ˜์Œ์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

int lastIndexOf(Object o): ๋ฆฌ์ŠคํŠธ์—์„œ ํŠน์ • ์š”์†Œ๊ฐ€ ๋งˆ์ง€๋ง‰์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

int lastIndexOfRange(Object o, int start, int end): ์ง€์ •๋œ ๋ฒ”์œ„ ๋‚ด์—์„œ ํŠน์ • ์š”์†Œ๊ฐ€ ๋งˆ์ง€๋ง‰์œผ๋กœ ๋‚˜ํƒ€๋‚˜๋Š” ์ธ๋ฑ์Šค๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

Object clone(): ๋ฆฌ์ŠคํŠธ์˜ ๋ณต์‚ฌ๋ณธ์„ ์ƒ์„ฑํ•˜์—ฌ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

Object[] toArray(): ๋ฆฌ์ŠคํŠธ์˜ ๋ชจ๋“  ์š”์†Œ๋ฅผ ํฌํ•จํ•˜๋Š” ๋ฐฐ์—ด์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

E get(int index): ์ง€์ •๋œ ์ธ๋ฑ์Šค์— ์žˆ๋Š” ์š”์†Œ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

E set(int index, E element): ์ง€์ •๋œ ์ธ๋ฑ์Šค์— ์ƒˆ ์š”์†Œ๋ฅผ ์„ค์ •ํ•˜๊ณ , ์›๋ž˜ ์žˆ๋˜ ์š”์†Œ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

void add(E e, Object[] elementData, int s): ์š”์†Œ๋ฅผ ๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค. ์ฃผ๋กœ ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

boolean add(E e): ์š”์†Œ๋ฅผ ๋ฆฌ์ŠคํŠธ์˜ ๋์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

void add(int index, E element): ์ง€์ •๋œ ์ธ๋ฑ์Šค์— ์š”์†Œ๋ฅผ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

E remove(int index): ์ง€์ •๋œ ์ธ๋ฑ์Šค์˜ ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ , ๊ทธ ์š”์†Œ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

boolean equals(Object o): ๋‘ ๋ฆฌ์ŠคํŠธ๊ฐ€ ๋™์ผํ•œ์ง€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค.

boolean equalsRange(List<?> other, int from, int to): ๋ฆฌ์ŠคํŠธ์˜ ํŠน์ • ๋ฒ”์œ„๊ฐ€ ๋‹ค๋ฅธ ๋ฆฌ์ŠคํŠธ์˜ ํ•ด๋‹น ๋ฒ”์œ„์™€ ๊ฐ™์€์ง€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค.

boolean equalsArrayList(ArrayList<?> other): ๋‘ ArrayList ๊ฐ์ฒด๊ฐ€ ๊ฐ™์€์ง€ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค.

void checkForComodification(final int expectedModCount): ์ดํ„ฐ๋ ˆ์ดํ„ฐ ์ƒ์„ฑ ์ดํ›„ ๋ฆฌ์ŠคํŠธ๊ฐ€ ๊ตฌ์กฐ์ ์œผ๋กœ ์ˆ˜์ •๋˜์—ˆ๋Š”์ง€ ํ™•์ธํ•˜๋Š” ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. ์ˆ˜์ • ํšŸ์ˆ˜(modCount)๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ expectedModCount์™€ ๋ฆฌ์ŠคํŠธ์˜ modCount๋ฅผ ๋น„๊ตํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅด๋ฉด ConcurrentModificationException์„ ๋ฐœ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค.

int hashCode(): ๋ฆฌ์ŠคํŠธ์˜ ํ•ด์‹œ ์ฝ”๋“œ๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ์— ์žˆ๋Š” ์š”์†Œ๋“ค์˜ ํ•ด์‹œ ์ฝ”๋“œ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ๊ณ„์‚ฐ๋ฉ๋‹ˆ๋‹ค.

int hashCodeRange(int from, int to): ๋ฆฌ์ŠคํŠธ์˜ ํŠน์ • ๋ฒ”์œ„(from ์ธ๋ฑ์Šค๋ถ€ํ„ฐ to ์ธ๋ฑ์Šค๊นŒ์ง€)์— ์žˆ๋Š” ์š”์†Œ๋“ค์˜ ํ•ด์‹œ ์ฝ”๋“œ๋ฅผ ๊ณ„์‚ฐํ•ฉ๋‹ˆ๋‹ค.

boolean remove(Object o): ๋ฆฌ์ŠคํŠธ์—์„œ ์ง€์ •๋œ ์š”์†Œ์˜ ์ฒซ ๋ฒˆ์งธ ๋ฐœ์ƒ์„ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. ๋ฆฌ์ŠคํŠธ์— ์ง€์ •๋œ ์š”์†Œ๊ฐ€ ์žˆ์—ˆ๋‹ค๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

void fastRemove(Object[] es, int i): ๋ฒ”์œ„ ๊ฒ€์‚ฌ๋‚˜ modCount ์—…๋ฐ์ดํŠธ ์—†์ด ์ง€์ •๋œ ์ธ๋ฑ์Šค์—์„œ ์š”์†Œ๋ฅผ ๋น ๋ฅด๊ฒŒ ์ œ๊ฑฐํ•˜๋Š” ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค.

void clear(): ๋ฆฌ์ŠคํŠธ์—์„œ ๋ชจ๋“  ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

boolean addAll(Collection<? extends E> c): ์ง€์ •๋œ ์ปฌ๋ ‰์…˜์— ์žˆ๋Š” ๋ชจ๋“  ์š”์†Œ๋ฅผ ๋ฆฌ์ŠคํŠธ์˜ ๋์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

boolean addAll(int index, Collection<? extends E> c): ์ง€์ •๋œ ์ปฌ๋ ‰์…˜์— ์žˆ๋Š” ๋ชจ๋“  ์š”์†Œ๋ฅผ ๋ฆฌ์ŠคํŠธ์˜ ์ง€์ •๋œ ์œ„์น˜์— ์‚ฝ์ž…ํ•ฉ๋‹ˆ๋‹ค.

void removeRange(int fromIndex, int toIndex): ๋ฆฌ์ŠคํŠธ์—์„œ ํŠน์ • ๋ฒ”์œ„์˜ ์š”์†Œ๋ฅผ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค(fromIndex๋ถ€ํ„ฐ toIndex๊นŒ์ง€, toIndex๋Š” ํฌํ•จํ•˜์ง€ ์•Š์Œ).

void shiftTailOverGap(Object[] es, int lo, int hi): ๋ฒ”์œ„์˜ ์š”์†Œ๊ฐ€ ์ œ๊ฑฐ๋  ๋•Œ ๋‚ด๋ถ€ ๋ฐฐ์—ด์—์„œ ์š”์†Œ๋“ค์„ ์ด๋™์‹œํ‚ค๋Š” ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค.

String outOfBoundsMsg(int index): IndexOutOfBoundsException ๋ฉ”์‹œ์ง€๋ฅผ ํ‘œ์ค€ํ™”ํ•˜์—ฌ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

boolean removeAll(Collection<?> c): ์ง€์ •๋œ ์ปฌ๋ ‰์…˜์— ํฌํ•จ๋œ ์š”์†Œ๋“ค์„ ๋ฆฌ์ŠคํŠธ์—์„œ ๋ชจ๋‘ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

boolean retainAll(Collection<?> c): ์ง€์ •๋œ ์ปฌ๋ ‰์…˜์— ํฌํ•จ๋œ ์š”์†Œ๋“ค๋งŒ ๋ฆฌ์ŠคํŠธ์—์„œ ์œ ์ง€ํ•ฉ๋‹ˆ๋‹ค.

batchRemove(Collection<?> c, boolean complement, final int from, final int end): ์š”์†Œ๋“ค์„ ์ผ๊ด„์ ์œผ๋กœ ์ œ๊ฑฐํ•˜๊ธฐ ์œ„ํ•œ ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. complement๊ฐ€ true์ด๋ฉด ์ง€์ •๋œ ์ปฌ๋ ‰์…˜์—๋„ ํฌํ•จ๋œ ์š”์†Œ๋“ค๋งŒ ์œ ์ง€ํ•˜๊ณ , ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค.

void writeObject(java.io.ObjectOutputStream s): ArrayList์˜ ์‚ฌ์šฉ์ž ์ •์˜ ์ง๋ ฌํ™” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. ์ด ๋ฉ”์„œ๋“œ๋Š” ArrayList ๊ฐ์ฒด๋ฅผ ์ŠคํŠธ๋ฆผ์— ์ง๋ ฌํ™”ํ•˜์—ฌ ๋‚˜์ค‘์— ์—ญ์ง๋ ฌํ™”ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ƒํƒœ๋ฅผ ๋ณด์กดํ•ฉ๋‹ˆ๋‹ค.

void readObject(java.io.ObjectInputStream s): ๊ฐ์ฒด์˜ ์—ญ์ง๋ ฌํ™”๋ฅผ ์œ„ํ•œ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. java.io.ObjectInputStream์„ ์‚ฌ์šฉํ•ด ์ŠคํŠธ๋ฆผ์—์„œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์™€ ๊ฐ์ฒด๋ฅผ ๋ณต์›ํ•ฉ๋‹ˆ๋‹ค.

ListIterator<E> listIterator(int index): ์ง€์ •๋œ ์ธ๋ฑ์Šค์—์„œ ์‹œ์ž‘ํ•˜๋Š” ListIterator๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ด ์ดํ„ฐ๋ ˆ์ดํ„ฐ๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ์–‘๋ฐฉํ–ฅ์œผ๋กœ ์ˆœํšŒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Iterator<E> iterator(): ๋ฆฌ์ŠคํŠธ๋ฅผ ์ˆœํšŒํ•˜๊ธฐ ์œ„ํ•œ Iterator๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

List<E> subList(int fromIndex, int toIndex): ๋ฆฌ์ŠคํŠธ์˜ ์ผ๋ถ€๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” subList๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„ ๋ฆฌ์ŠคํŠธ๋Š” ์›๋ณธ ๋ฆฌ์ŠคํŠธ์˜ fromIndex๋ถ€ํ„ฐ toIndex๊นŒ์ง€์˜ ๋ฒ”์œ„๋ฅผ ํฌํ•จํ•ฉ๋‹ˆ๋‹ค.

void forEach(Consumer<? super E> action): ๋ฆฌ์ŠคํŠธ์˜ ๊ฐ ์š”์†Œ์— ๋Œ€ํ•ด ์ง€์ •๋œ ์•ก์…˜(ํ•จ์ˆ˜)์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. Consumer ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

Spliterator<E> spliterator(): ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” Spliterator ๊ฐ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

long[] nBits(int n): ๋‚ด๋ถ€์ ์œผ๋กœ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์„œ๋“œ๋กœ, ์ฃผ์–ด์ง„ ํฌ๊ธฐ์˜ ๋น„ํŠธ ๋ฐฐ์—ด์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

void setBit(long[] bits, int i): ๋น„ํŠธ ๋ฐฐ์—ด์—์„œ ํŠน์ • ์œ„์น˜์˜ ๋น„ํŠธ๋ฅผ ์„ค์ •ํ•˜๋Š” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค.

boolean isClear(long[] bits, int i): ๋น„ํŠธ ๋ฐฐ์—ด์—์„œ ํŠน์ • ์œ„์น˜์˜ ๋น„ํŠธ๊ฐ€ ์ง€์›Œ์กŒ๋Š”์ง€(0์ธ์ง€) ํ™•์ธํ•˜๋Š” ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค.

boolean removeIf(Predicate<? super E> filter): ์ง€์ •๋œ ์กฐ๊ฑด(ํ•„ํ„ฐ)์— ๋งž๋Š” ์š”์†Œ๋“ค์„ ๋ฆฌ์ŠคํŠธ์—์„œ ์ œ๊ฑฐํ•ฉ๋‹ˆ๋‹ค. Predicate ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

void replaceAll(UnaryOperator<E> operator): ๋ฆฌ์ŠคํŠธ์˜ ๋ชจ๋“  ์š”์†Œ๋ฅผ ์ง€์ •๋œ ์—ฐ์‚ฐ์ž๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋Œ€์ฒดํ•ฉ๋‹ˆ๋‹ค. UnaryOperator ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

void checkInvariants(): ArrayList์˜ ๋‚ด๋ถ€ ๋ถˆ๋ณ€์„ฑ์„ ํ™•์ธํ•˜๋Š” ๋‚ด๋ถ€ ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. ์ผ๊ด€์„ฑ๊ณผ ์˜ค๋ฅ˜๋ฅผ ๊ฒ€์‚ฌํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค.

void trimToSize(), void ensureCapacity(int minCapacity), Object[] grow(int minCapacity) , int newCapacity(int minCapacity), int hugeCapacity(int minCapacity), int size(), boolean isEmpty(), boolean contains(Object o), int indexOf(Object o), indexOfRange(Object o, int start, int end) , int lastIndexOf(Object o), lastIndexOfRange(Object o, int start, int end) , Object clone(), Object[] toArray(), E get(int index) , E set(int index, E element), void add(E e, Object[] elementData, int s), boolean add(E e), void add(int index, E element), E remove(int index), boolean equals(Object o), boolean equalsRange(List<?> other, int from, int to), boolean equalsArrayList(ArrayList<?> other) , void checkForComodification(final int expectedModCount), int hashCode() , int hashCodeRange(int from, int to), boolean remove(Object o) , void fastRemove(Object[] es, int i) , void clear(), boolean addAll(Collection<? extends E> c) , boolean addAll(int index, Collection<? extends E> c) , void removeRange(int fromIndex, int toIndex), void shiftTailOverGap(Object[] es, int lo, int hi) , String outOfBoundsMsg(int index), boolean removeAll(Collection<?> c), boolean retainAll(Collection<?> c), batchRemove(Collection<?> c, boolean complement, final int from, final int end) , void writeObject(java.io.ObjectOutputStream s), void readObject(java.io.ObjectInputStream s), ListIterator<E> listIterator(int index), Iterator<E> iterator(), List<E> subList(int fromIndex, int toIndex), void forEach(Consumer<? super E> action) , Spliterator<E> spliterator(), long[] nBits(int n), void setBit(long[] bits, int i), boolean isClear(long[] bits, int i), boolean removeIf(Predicate<? super E> filter), void replaceAll(UnaryOperator<E> operator) , void checkInvariants()

 

ArrayList ํด๋ž˜์Šค๋ฅผ ๋œฏ์–ด๋ณด๋‹ˆ ๋‚ด๋ถ€ ํด๋ž˜์Šค๊ฐ€ ๊ฝค๋‚˜ ์กด์žฌํ•œ๋‹ค.

GPT๋กœ ๊ณต๋ถ€ํ•˜๊ธฐ


ArrayList ํด๋ž˜์Šค ๋‚ด์—๋Š” ๋ช‡ ๊ฐ€์ง€ ์ค‘์š”ํ•œ ๋‚ด๋ถ€ ํด๋ž˜์Šค๋“ค์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋“ค์€ ์ฃผ๋กœ ArrayList์˜ ์ž‘๋™์„ ๋ณด์กฐํ•˜๊ณ , ์ปฌ๋ ‰์…˜ ํ”„๋ ˆ์ž„์›Œํฌ์™€์˜ ์ƒํ˜ธ์ž‘์šฉ์„ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ์กด์žฌํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋‚ด๋ถ€ ํด๋ž˜์Šค๋“ค์ด ํฌํ•จ๋ฉ๋‹ˆ๋‹ค

Itr: ์ด๊ฒƒ์€ ArrayList์˜ ๊ธฐ๋ณธ ์ดํ„ฐ๋ ˆ์ดํ„ฐ ๊ตฌํ˜„์ž…๋‹ˆ๋‹ค. Iterator ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉฐ, ๋ฆฌ์ŠคํŠธ์˜ ์š”์†Œ๋ฅผ ์ˆœ์ฐจ์ ์œผ๋กœ ์ˆœํšŒํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ์ด ์ดํ„ฐ๋ ˆ์ดํ„ฐ๋Š” fail-fast ๋™์ž‘์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, ์ดํ„ฐ๋ ˆ์ดํ„ฐ ์ƒ์„ฑ ํ›„ ๋ฆฌ์ŠคํŠธ๊ฐ€ ์ˆ˜์ •๋˜๋ฉด ConcurrentModificationException์„ ๋ฐœ์ƒ์‹œํ‚ต๋‹ˆ๋‹ค.

ListItr: ListIterator ์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ตฌํ˜„์ฒด๋กœ, Itr๋ฅผ ํ™•์žฅํ•ฉ๋‹ˆ๋‹ค. ์ด ์ดํ„ฐ๋ ˆ์ดํ„ฐ๋Š” ์–‘๋ฐฉํ–ฅ(์•ž์œผ๋กœ ๋ฐ ๋’ค๋กœ) ์ˆœํšŒ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๊ณ , ๋ฆฌ์ŠคํŠธ์˜ ํŠน์ • ์œ„์น˜์— ์š”์†Œ๋ฅผ ์ถ”๊ฐ€ํ•˜๊ฑฐ๋‚˜ ์‚ญ์ œํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

SubList: ArrayList์˜ subList ๋ฉ”์„œ๋“œ์— ์˜ํ•ด ๋ฐ˜ํ™˜๋˜๋Š” ๋ถ€๋ถ„ ๋ฆฌ์ŠคํŠธ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๋‚ด๋ถ€ ํด๋ž˜์Šค์ž…๋‹ˆ๋‹ค. ์ด ํด๋ž˜์Šค๋Š” ์›๋ณธ ๋ฆฌ์ŠคํŠธ์˜ ํŠน์ • ๋ถ€๋ถ„์— ๋Œ€ํ•œ ๋ทฐ๋ฅผ ์ œ๊ณตํ•˜๋ฉฐ, ๋ถ€๋ถ„ ๋ฆฌ์ŠคํŠธ์— ๋Œ€ํ•œ ๋ณ€๊ฒฝ์‚ฌํ•ญ์€ ์›๋ณธ ๋ฆฌ์ŠคํŠธ์—๋„ ๋ฐ˜์˜๋ฉ๋‹ˆ๋‹ค.

ArrayListSpliterator: Spliterator ์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ตฌํ˜„์ฒด๋กœ, ArrayList์˜ ๋ณ‘๋ ฌ ์ฒ˜๋ฆฌ ๊ธฐ๋Šฅ์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. ์ด ์Šคํ”Œ๋ฆฌํ„ฐ๋ ˆ์ดํ„ฐ๋Š” ๋ฆฌ์ŠคํŠธ๋ฅผ ์—ฌ๋Ÿฌ ๋ถ€๋ถ„์œผ๋กœ ๋ถ„ํ• ํ•˜์—ฌ ๋ณ‘๋ ฌ ์ŠคํŠธ๋ฆผ ์ž‘์—…์— ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค.


์ด ๋‚ด๋ถ€ ํด๋ž˜์Šค๋“ค์€ ArrayList์˜ ๊ธฐ๋Šฅ์„ ํ™•์žฅํ•˜๊ณ , Java์˜ ์ปฌ๋ ‰์…˜ ํ”„๋ ˆ์ž„์›Œํฌ์™€์˜ ํ†ตํ•ฉ์„ ๊ฐ•ํ™”ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ ํด๋ž˜์Šค๋Š” ํŠน์ • ๋ชฉ์ ์— ๋งž๊ฒŒ ์„ค๊ณ„๋˜์—ˆ์œผ๋ฉฐ, ArrayList๋ฅผ ๋ณด๋‹ค ์œ ์—ฐํ•˜๊ณ  ํšจ์œจ์ ์œผ๋กœ ๋งŒ๋“œ๋Š” ๋ฐ ๊ธฐ์—ฌํ•ฉ๋‹ˆ๋‹ค.