Jump to content

general dynamic queue in PHP


delk13

Recommended Posts

Hi to all the members of this great community,

 

This is my first post here and I am new in PHP and in general web programming, my background is in C and C++ programming languages that's why I want to make some comments with regards to PHP and getting your feedbacks.

 

In C++ one exercise considered that someone knows the basics of the language is to implement a general dynamic queue that is the client programmer can put an arbitrary number of objects into a queue and using templates you can instantiate different queues holding different kind of objects.

 

I have grasped the most important parts of the language and I am pondering if you can effectively implement something like the above using PHP.

 

I have googled this, and I have seen so far just a very simple implementation in PHP.

He has defined his queue using an array having a fixed size and he just moved an index up and down through the array while inserting and poping elements from the queue.

 

if you want to implement a dynamic queue the only way it comes to my mind just off the top of my head is to

use the the construct [] to add dynamically element at the end of the queue and when you want to pop up an element you just have to

unset(your current queue which is an array)

create another array (smaller by one element than the previous one)

copy the elements at the appropriate positions

 

I just wanted, people with a C++ programming experience to give me some feedback about this topic and to give me some basic idea how could we implement a general queue in PHP.

For example could we implement a queue w/o using an array?

 

I would appreciate any comment.

 

Greetings from Greece

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.