c++ - FIFO implementation -
When I applied a FIFO, I used the following structure:
struct node { T info_; Node * link_; Node (t information, node * link = 0): info_ (info), link_ (link) {}};
I think that this is a famous move for a lot of STL containers (for example, for the list). Is this a good practice? What does this mean for the compiler when you say that the node has a type of pointer? Is this an eternal loop?
And finally, if this is a bad practice, then how can I apply a better FIFA?
EDIT: People, this is all about non-affiliation. I am quite familiar with the STL library, and have discovered many containers from many libraries. I just want to discuss with those people who can do good implementation or good advice.
The manner in which it is being declared is correct in both C and C ++. This is based on the fact that the pointers are fixed size objects (say, 32-bit integers on 32-bit platforms) so that you do not need full type of type-to-type to be known.
Basically, you do not need to declare a full type of announcement to declare an indicator. Further announcement will be sufficient:
class A; // Next declare type structure B {A * pa; // & LT; Pointer to A - Completely Legal};
Of course, you need a complete declaration in the scope at this point where you actually use members:
#include & lt; A.hpp & gt; // Bring in the full declaration of class A ... bb; B.P.A. = & Amp; a; //An example of some examples ... b.pa-> func (); // Call the AA member function - This requires full declaration
Look for std :: queue
for FIFO. Both the std :: list
, std :: deque
, and std :: vector
can be used for that purpose, but the other Facilities can also be provided.
Comments
Post a Comment