목차
1. Deque 코딩
2. 실행 모습
3. 설명
2. 실행 모습
3. 설명
본문내용
-->혹은 rear에서 삽입을 선택하게 된다면
temp_1=ads(rear+1); temp_1에 rear의 다음 주소를 넣는다.
temp_2=front; temp_2에는 front값을 넣는다.
}
if(temp_1==temp_2) { --->temp_1과 temp_2가 같다면
deque_full(); deque는 가득 찬 것이다.
return;
}
if(key == 1) { --->다시 front에 삽입이 일어나게 된다면
front=temp_1; front에 temp_1값을 넣는다.
temp_1=ads(front+1); temp_2에는 front 다음 주소를 넣는다.
}
else {
rear=temp_1; --->혹 다시 삽입이 없을 때 rear에 temp_1값을 넣는다
}
deque[temp_1] = content;
}
element Delete_deque(int key) --->삭제 메뉴를 선택하였을 경우
{
int tmp;
if (front == rear) return deque_empty(); -->front와 rear가 같을 땐 deque가 비었다.
if (key == 1) { --->front에서 삭제를 선택하게 된다면
tmp = front; tmp에 front를 넣는다.
front=ads(front+1); 그리고 front에는 다음 front 주소를 넣는다.
}
else { --->rear에서 삭제를 선택하게 된다면
tmp = rear; tmp에 rear값을 넣는다.
rear=ads(rear-1); 그리고 rear에는 전 rear 주소를 넣는다.
}
return deque[tmp];
}
temp_1=ads(rear+1); temp_1에 rear의 다음 주소를 넣는다.
temp_2=front; temp_2에는 front값을 넣는다.
}
if(temp_1==temp_2) { --->temp_1과 temp_2가 같다면
deque_full(); deque는 가득 찬 것이다.
return;
}
if(key == 1) { --->다시 front에 삽입이 일어나게 된다면
front=temp_1; front에 temp_1값을 넣는다.
temp_1=ads(front+1); temp_2에는 front 다음 주소를 넣는다.
}
else {
rear=temp_1; --->혹 다시 삽입이 없을 때 rear에 temp_1값을 넣는다
}
deque[temp_1] = content;
}
element Delete_deque(int key) --->삭제 메뉴를 선택하였을 경우
{
int tmp;
if (front == rear) return deque_empty(); -->front와 rear가 같을 땐 deque가 비었다.
if (key == 1) { --->front에서 삭제를 선택하게 된다면
tmp = front; tmp에 front를 넣는다.
front=ads(front+1); 그리고 front에는 다음 front 주소를 넣는다.
}
else { --->rear에서 삭제를 선택하게 된다면
tmp = rear; tmp에 rear값을 넣는다.
rear=ads(rear-1); 그리고 rear에는 전 rear 주소를 넣는다.
}
return deque[tmp];
}
소개글