Queue is a data structure designed to operate in FIFO (First in First out) context. In queue elements are inserted from rear end and get removed from front end.
Queue class is container adapter. Container is an objects that hold data of same type. Queue can be created from different sequence containers. Container adapters do not support iterators therefore we cannot use them for data manipulation. However they support push() and pop() member functions for data insertion and deletion respectively.
DefinitionBelow is definition of std::queuer from <queue> header file
template <class T, class Container = deque<T> > class queue;Parameters
T − Type of the element contained.
T may be substituted by any other data type including user-defined type.
Container − Type of the underlying container object.
Following member types can be used as parameters or return type by member functions.
Sr.No. Member types Definition 1 value_type T (First parameter of the template) 2 container_type Second parameter of the template 3 size_type size_t 4 reference value_type& 5 const_reference const value_type& 6 difference_type ptrdiff_t Functions from <queue>Below is list of all methods from <queue> header.
Constructors Sr.No. Method & Description 1 queue::queueConstructs an empty queue object, with zero elements.
Destructor Sr.No. Method & Description 1 queue::~queueDestroys queue by deallocating container memory.
Member functions Sr.No. Method & Description 1 queue::backReturns a reference to the last element of queue.
2 queue::emplaceConstructs and inserts new element at the end of queue.
3 queue::emptyTests whether queue is empty or not.
4 queue::frontReturns a reference to the first element of the queue.
5 queue::operator=Assigns new contents to the queue by replacing old ones.
6 queue::popRemoves front element of the queue.
7 queue::pushInserts new element at the end of queue.
8 queue::sizeReturns the total number of elements present in the queue.
9 queue::swapExchanges the contents of queue with contents of another queue.
Non-member overloaded functions Sr.No. Method & Description 1 operator==Tests whether two queues are equal or not.
2 operator!=Tests whether two queues are equal or not.
3 operator<Tests whether first queue is less than other or not.
4 operator<=Tests whether first queue is less than or equal to other or not.
5 operator>Tests whether first queue is greater than other or not.
6 operator>=Tests whether first queue is greater than or equal to other or not.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4