728x90
public String get(int index){
return (String) data[index];
}
public void set(int index, String value){
data[index] = value;
}
public void insert(int index, String value){
//check size
if(size == initialCapacity){
resize();
}
//copy up
for(int j=size;j>index;j--){
data[j] = data[j-1];
}
data[index] = value;
}
public void delete(int index){
//copy down
for(int j=index; j>size; j++){
data[j] = data[j+1];
}
size--;
}
'Programming > Data Structure & Algorithms' 카테고리의 다른 글
Tell me about the array/arraylist/linkedlist difference ?? (0) | 2024.02.04 |
---|---|
[자료구조] 연결리스트로 Stack(스택) 구현해보기 (0) | 2024.01.23 |
[자료구조] 이진트리(Binary Tree)와 이진탐색트리(Binary Search Tree) (0) | 2024.01.12 |
[자료구조] 파이썬(Python) VS 자바(Java) 주요 자료구조 비교해보기 (0) | 2023.12.18 |
[자료구조] 자바 java.util.LinkedList의 주요 메소드 정리 (0) | 2023.12.17 |