simulate the process as given using doubly linked list in c++
Code\ncpp []\nclass FrontMiddleBackQueue {\npublic:\n    list<int>ll;\n    void print(){\n        for(auto it = ll.begin() ; it != ll.end() ; it++){\n          
# Code\n```cpp []\nclass FrontMiddleBackQueue {\npublic:\n    list<int>ll;\n    void print(){\n        for(auto it = ll.begin() ; it != ll.end() ; it++){\n            cout<<*(it)<<" ";\n        }\n        cout<<endl;\n    }\n    FrontMiddleBackQueue() {\n        \n    }\n    \n    void pushFront(int val) {\n          ll.push_front(val);\n         \n    }\n    \n    void pushMiddle(int val) {\n         //the ll could have the even size  [] , [1,2] , [1,2,3,4,5,6]  \n         if(ll.size() == 0){        //[]  --> push(1)  --> [1]\n            pushFront(val);\n         } \n         else if(ll.size() == 1)    //[1] --> push(2) --> [2,1]\n         {                          //beech wale k just pehle\n            pushFront(val);\n         }\n         else if((ll.size() % 2) == 0){   //[1,2] [1,2,3,4]\n               auto it = ll.begin();\n               int tempsize = ll.size()/2;\n               list<int>templist;\n\n               while(tempsize > 0){\n                    templist.push_back(*(it));\n                    it++;\n                    tempsize--;\n               }\n               templist.push_back(val);\n               tempsize = ll.size()/2;\n               while(it != ll.end()){\n                    templist.push_back(*(it));\n                    it++;\n                    tempsize--;\n               }\n               ll = templist;\n         }\n         else if((ll.size() % 2) != 0){   //the ll could have the odd size   [1] , [1,2,3] [1,2,3,4,5]\n              list<int>templist;\n              auto it = ll.begin();\n              int tempsize = (ll.size()/2);\n            //   cout<<"currlist = ";\n            //   print();\n            //   cout<<endl;\n              while(tempsize > 0){\n                 templist.push_back(*(it));\n                 it++;\n                 tempsize--;\n              }\n              templist.push_back(val);\n              while(it != ll.end()){\n                  templist.push_back(*(it));\n                  it++;\n              }\n              ll = templist;\n         }\n    }\n    \n    void pushBack(int val) {\n          ll.push_back(val);\n    }\n    \n    int popFront() {\n          if(ll.size() == 0) return -1;\n          int val = ll.front();\n          ll.pop_front();\n          \n          return val;\n    }\n    \n    int popMiddle() \n    {\n         int result;\n         if(ll.size() == 0){\n            result = -1;\n         }\n         else if(ll.size() == 1){\n             result = ll.front();\n             ll.pop_front();\n         }\n         else if((ll.size() % 2) == 0){    //if it has even elements  [1,2,3,4]\n               int tempsize = (ll.size()/2)-1;\n               auto it = ll.begin();\n               while(tempsize > 0){\n                     it++;\n                     tempsize--;\n               }\n               result = *(it);\n               ll.erase(it);\n         }\n         else if((ll.size() % 2) != 0){  //if it has odd elements [1,2,3,4,5]\n               int tempsize = (ll.size()/2);\n               auto it = ll.begin();\n               while(tempsize > 0){\n                     it++;\n                     tempsize--;\n               }\n               result = *(it);\n               ll.erase(it);\n         } \n         \n         return result;\n    }\n    \n    int popBack() {\n         if(ll.size() == 0) return -1;\n         int val = ll.back();\n         ll.pop_back();\n         \n         return val;\n    }\n};\n\n/**\n * Your FrontMiddleBackQueue object will be instantiated and called as such:\n * FrontMiddleBackQueue* obj = new FrontMiddleBackQueue();\n * obj->pushFront(val);\n * obj->pushMiddle(val);\n * obj->pushBack(val);\n * int param_4 = obj->popFront();\n * int param_5 = obj->popMiddle();\n * int param_6 = obj->popBack();\n */\n```
['Array', 'Linked List', 'Design', 'Queue', 'Data Stream', 'C++']