๐ฉ ํ(Queue)์ ์์ฉ_1) ์ด์์ฒด์ ์ ์์ ํ
๐ ํ๋ฆฐํฐ ๋ฒํผ ํ (Printer Buffer Queue)
: CPU์์ ํ๋ฆฐํฐ๋ก ๋ณด๋ธ ๋ฐ์ดํฐ ์์๋๋ก ํ๋ฆฐํฐ์์ ์ถ๋ ฅํ๊ธฐ ์ํด ์ ์ ์ ์ถ ๊ตฌ์กฐ์ ํ ์ฌ์ฉ
๐ ์ค์ผ์ค๋ง ํ (Scheduling Queue)
: CPU ์ฌ์ฉ์ ์์ฒญํ ํ๋ก์ธ์๋ค์ ์์๋ฅผ ์ค์ผ์ค๋งํ๊ธฐ ์ํด ํ ์ฌ์ฉ
๐ฉ ํ(Queue)์ ์์ฉ_2) ์๋ฎฌ๋ ์ด์ ์์์ ํ์ ์์คํ
: ์๋ฎฌ๋ ์ด์ ์ ์ํ ์ํ์ ๋ชจ๋ธ๋ง์์ ๋๊ธฐ ํ๋ ฌ ๋ฐ ๋๊ธฐ ์๊ฐ ๋ฑ์ ๋ชจ๋ธ๋งํ๊ธฐ ์ํด ํ์ ์ด๋ก (Queue Theory)์ ์ฌ์ฉํ๊ธฐ๋ ํ๋ค.
๐ฉ ๋ฐํฌ(Deque)๋?
๊ธฐ์กด์ ํ 2๊ฐ ์ค ํ๋๋ฅผ ์ข์ฐ๋ก ๋ค์ง์ ๊ฒฐํฉ์ํจ ๊ตฌ์กฐ๋ก, ํ์ ์์ชฝ ๋์์ ์ฝ์ ๊ณผ ์ญ์ ์ฐ์ฐ์ ๋ชจ๋ ์ํํ ์ ์๋๋ก ํ์ฅํ ์๋ฃ ๊ตฌ์กฐ๋ฅผ ๋ฐํฌ(Deque)๋ผ๊ณ ํ๋ค.
๐ ๋ฐํฌ์ ์ถ์ ์๋ฃํ
ADT deque
// ๊ณต๋ฐฑ ์ํ์ธ ๋ฐํฌ ์์ฑ
createDeque() ::= create an empty DQ;
//๋ฐํฌ๊ฐ ๊ณต๋ฐฑ ์ํ์ธ์ง ๊ฒ์ฌ
isEmpty(DQ) ::= if (DQ is empty) then return true
else return false;
//๋ฐํฌ์ front ์์ ์์ ์ฝ์
insertFront(DQ, item) ::= insert item at the front of DQ;
//๋ฐํฌ์ rear ๋ค์ ์์ ์ฝ์
insertRear(DQ, item) ::= insert item at the rear of DQ;
//๋ฐํฌ์ front์ ์๋ ์์ ์ญ์
deleteFront(DQ) ::= if (isEmpty(DQ)) then return NULL
else
{
delete and return the front item of DQ
};
//๋ฐํฌ์ rear์ ์๋ ์์ ์ญ์
deleteRear(DQ) ::= if (isEmpty(DQ)) then return NULL
else
{
delete and return the rear item of DQ
};
//๋ฐํฌ์ front์ ์๋ ์์ ๋ฐํ
getFront(DQ) ::= if (isEmpty(DQ)) then return NULL
else
{
return the front item of DQ
};
//๋ฐํฌ์ rear์ ์๋ item ๋ฐํ
getRear(DQ) ::= if (isEmpty(DQ)) then return NULL
else
{
return the rear item of DQ
};
End deque