Linux??????????????????????
?????Linux ???????[ 2014/10/21 10:53:36 ] ????????Linux ?????? ???
???????
????????????????????У?????Linux??????/????????????????????????????????????????????漰????????л??????£?
?????????????????????????????????
????? ???????????
????1.1 ?????????ж???
???????????????????????????????????????????β????(???)??????????(????)??????????????μ??β????????????????????????????
???????е????洢??????????????????????????????????£?
????1 struct Queue{
????2 ElemType elem[MaxSize];
????3 int head?? tail;
????4 };
??????????????elem???洢?????е????????????????????head??tail???洢?????????β(???β?????)?????±?λ?????????????????β???MaxSize??????洢???е????????????ж?????洢???????????????е????洢??侲????????MaxSize???????壻????????????????????????????
?????????????д???“?????”???????????????????????????????λ?????β??????????к???????λ???????????μ??????????????????????????????β????????????????????????????????????????????????????й??????????????β?????????????????е??MaxSize-1??λ?????ú?????????п?????????μ?????????????е?0??λ?á?????????????????????????????н???
???????????MaxSize=4??????????????????
???????У????????????????????????????????(????±??3??λ??)????????????????head????????????β???tail????β????????????????β????1???????????ж??????????
???????????head = tail = 0??
???????п??head == tail??
????????????(tail + 1) % MaxSize == head??
???????????num = (tail - head + MaxSize) % MaxSize
????%???????????????????????????????????β??????????
?????????head??????????????tail????β????????????????????????????????head??????????tail????β?????????????(tail - head + 1 + MaxSize) % MaxSize??
??????????????????????????????????????????????????????λ????????????????????
??????????????λ?ú??????????????????????β???????λ?á?????????????????????????β???(????????)???????????????
???????п??num == 0??
????????????num == MaxSize??
??????βλ???tail = (head + num + MaxSize) % MaxSize
????1.2 ?????????????
?????????????C??????????????????????????????????????
?????????????????н????£?
????1 #define QUEUE_SIZE 5 //???д?????QUEUE_SIZE-1?????
????2 typedef struct{
????3 int aData[QUEUE_SIZE]; //???????
????4 int dwHead; //?????????
????5 int dwTail; //????β????????????
????6 }T_QUEUE?? *PT_QUEUE;
??????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11