Differences between deque::assign and deque::empty

Basis

deque::assign

deque::empty

Definition It is used to assign new contents to the deque container. It is used to check whether a deque is empty or not.
Syntax dequename.assign(<int> size, <int> val); empty()
Number of Parameters It takes only two parameters None
Return Value None Boolean
Complexity Linear Constant


Difference Between deque::assign and deque::empty in C++

Deque or Double-ended queues are sequence containers with the feature of expansion and contraction on both ends. They are similar to vectors, but are more efficient in the case of insertion and deletion of elements at the end, and also the beginning. Unlike vectors, contiguous storage allocation may not be guaranteed.

 Here we will see the difference between deque::assign and deque::at in C++.

Similar Reads

deque::assign

deque::assign is used to assign new contents to the deque container by replacing its current contents. It changes its size accordingly....

deque::empty

...

Differences between deque::assign and deque::empty

deque::empty is used to check whether the deque container is empty or not. It does not change anything in the container....

Contact Us