Data Structure, Queue and Link List

I wonder that can a queue containing data of link list type? I mean each data that store inside a queue is link-list type... Is that possible if I want to make it happened?
Last edited on
> I wonder that can a queue containing data of link list type?

Yes, if the linked list is copyable and destructible.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <list>
#include <queue>

int main()
{
    std::list<int> a = { 0, 1, 2, 3 } ;
    std::list<int> b = { 4, 5, 6, 7, 8, 9 } ;
    std::list<int> c ;

    std::queue< std::list<int> > q ;
    q.push(a) ;
    q.push(b) ;
    q.push(c) ;
}
if i want to create them manually, will this works?
1
2
3
4
5
6
7
8
9
10
11
12
struct node
{
   int data;
   node *link;
};

struct queue
{
  node list;        //feel something wrong here
  queue *qlink;
};

i try something up there and there error and i donno hw to fix it... please help...
Topic archived. No new replies allowed.