본문 바로가기

자료구조 구현하기

(7)
Map Class Diagram Method 1) get 2) put 3) remove https://github.com/diqksrk/datastructure GitHub - diqksrk/datastructure Contribute to diqksrk/datastructure development by creating an account on GitHub. github.com
2. Class ArrayList public class MyarrayList implements MyList { private static final int DEFALUT_CAPACITY = 10; private static final Object[] EMPTY_ARRAY = {}; private int size = 0; Object[] array; public arrayList() { this.array = EMPTY_ARRAY; this.size = 0; } public arrayList(int capacity) { this.array = new Object[capacity]; this.size = 0; } public void addLast(E value) { if (size == array.length) { resize(); }..
1. interface List public interface MyList extends MyCollection { E get(int index); E set(int index, E element); void add(int index, E element); E remove(int index); int indexOf(Object o); int lastIndexOf(Object o); List subList(int fromIndex, int toIndex); } 메소드 설명 1. get(int index) : 배열속에 특정 인덱스 값을 가져온다. 2. set(int index, E element) : 배열속에 특정 인덱스에 값을 수정한다. 3. add(int index, E element) : 배열속에 특정 인덱스에 값을 삽입한다. 4. ..
1. interface List interface List
0. interface Collection 메소드 설명 public interface myCollection { int size(); boolean isEmpty(); boolean contains(Object o); Object[] toArray(); boolean add(E e); boolean remove(Object o); boolean containsAll(Collection c); boolean addAll(Collection c); void clear(); } 1. size() : 내부 배열 사이즈를 반환한다. 2. isEmpty() : 내부 배열이 비었는지 아닌지를 확인한다. 3. contatins(Object o) : 전달받은 객체가 포함되어 있는지 여부를 확인한다. 4. toArray() : object 배열을 반환한다. 5. ..
0. 계층도 계층도를 보면 Collection inteface를 List가 extends하고 ArrayList와 Vector는 그 List를 implements한다. 따라서, 1단계로 ArrayList 구현을 목표로 잡고 실행한다. 1단계 : 2022년 6월 8일 ~ 2022년 6월 10일까지 진행.
취지 자료구조 기초가 부족함을 느끼고 직접 자료구조를 구현해보려고 한다. 순서는 ArrayList -> LinkedLIst -> Stack -> Queue -> Heap 순서로 진행한다.