We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,415 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Queues: Limited or Unlimited Size?

Hi,

I am learning queues and I have found 2 examples. Both examples represent queues with limited size, for example 30.
But <queue> allows us to create queue that is not limited by *pre-set queue size.

Can anyone explain me how have they created something like that?

Thanks!

By *pre-set I wanted to say that we have set the queue size during its initialization. Like when we create the arrays.

2
Contributors
2
Replies
10 Minutes
Discussion Span
1 Year Ago
Last Updated
3
Views
MrEARTHSHAcKER
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

The default back-end for std::queue is std::deque, which grows and shrinks dynamically. std::queue is actually a form of adapter that sits on top of a data structure to provide a convenient interface. std::stack is the same way.

std::deque is implemented in a somewhat confusing way, so you might consider studying how std::vector works intead (it's basically a dynamic array). It grows dynamically as well, but in a much more intuitive manner. That should get you rolling on answering the question: "how have they created something like that?". :)

deceptikon
Challenge Accepted
Administrator
3,457 posts since Jan 2012
Reputation Points: 822
Solved Threads: 474
Skill Endorsements: 57

Thank you!

MrEARTHSHAcKER
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 1
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.1429 seconds using 2.76MB