Double Linked List는 양방향 탐색이 가능한 구조이다.
class DoubleLinkedList {
constructor(id, value){
this.id = id;
this.value = value;
this._prevLink = null;
this._nextLink = null;
}
get prevLink(){return this._prevLink;}
set prevLink(prevLinkV){this._prevLink = prevLinkV;}
get nextLink(){return this._nextLink;}
set nextLink(nextLinkV){this._nextLink = nextLinkV;}
}
const dLink1 = new DoubleLinkedList('dLink1', '고잔');
const dLink2 = new DoubleLinkedList('dLink2', '중앙');
const dLink3 = new DoubleLinkedList('dLink3', '한대앞');
dLink1.prevLink = null;
dLink1.nextLink = dLink2;
dLink2.prevLink = dLink1;
dLink2.nextLink = dLink3;
dLink3.prevLink = dLink2;
dLink3.nextLink = null;
document.write(dLink1.nextLink.value);
반응형
'JAVASCRIPT' 카테고리의 다른 글
JAVASCRIPT ) 객체 delete (0) | 2024.08.06 |
---|---|
JAVASCRIPT ) canvas로 데이터 시각화 (0) | 2024.08.02 |
JAVASCRIPT ) singly Linked List (0) | 2024.07.31 |
JAVASCRIPT ) map() (0) | 2024.07.30 |
JAVASCRIPT ) sort() (0) | 2024.07.30 |