Questions tagged [stddeque]

std::deque is the C++ implementation of a double-ended queue provided by the STL

std::deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion at both its beginning and its end. See here for more information.

31 questions
1
vote
0 answers

Copy from std::deque to thrust device_vector

I'm trying to make a sample code where I copy from a std::deque to a thrust::device_vector but the compiler warns calling a __host__ function from a __host__ __device__ function is not allowed (I tried to copy-paste the entire error here but it is…
Marco
  • 827
  • 6
  • 18
1
vote
3 answers

Why use std::stack or std::queue?

Why would I use a std::stack or a std::queue rather than a std::vector or a std::deque? Since the container adapters are merely wrappers around the standard containers, why use them at all?
oz1cz
  • 5,504
  • 6
  • 38
  • 58
0
votes
1 answer

deque::end results in assertion failure

I was coding some code which needs a deque of structs. Only after 300 lines of repeatedly debugged code and excessive over-engineering, I found out that using the deque::end function somehow doesn't work in this code. Below is a simplified version…
0
votes
0 answers

Is it safe to access the popped binary tree nodes which iterative traversed by std::stack

Considering the Solution of Leetcode 94. Binary Tree Inorder Traversal. What confusing me is whether is is safe to access the node after the node being popped(stk.pop(); res.push_back(root->val);). I know that the underline container of std::stack…
amont
  • 81
  • 8
0
votes
1 answer

What is underlying data structure of std::deque and how does it's iterator work?

I know that std::deque has the different chunks of contiguous memory and iterator is invalidated by inserting or erasing the middle of deque. In addition to it, if I insert to the end side of element of deque, iterator is not valid but reference is…
myoldgrandpa
  • 871
  • 7
  • 21
0
votes
0 answers

Why is there a significant time and memory difference between the two similar implementations?

I was attempting the Leetcode Problem 239(Sliding Window Maximum). Consider the two implementations, Sol1 and Sol2. Sol1: class Solution { public: vector maxSlidingWindow(vector& nums, int k) { deque dq; …
Sharvani
  • 11
  • 3
0
votes
1 answer

What is the internal container used in tbb::concurrent_bounded_queue?

I know that std::queue uses a std::deque by default as its internal container. I could not find the same info for TBB. I have a legacy multithreaded application that currently uses a thread-safe wrapper around a std::queue>…
Suhail Khan
  • 190
  • 1
  • 1
  • 7
0
votes
2 answers

looping through a std::deque and remove entries

I am trying to iterate through a std::deque and remove all of its content. I can do it along the way: for(auto & x: myDeque) { // do something myDeque.pop_front(); } Or I can do myDeque.clear() at the end after the loop. I am wondering…
Ryan
  • 219
  • 2
  • 11
0
votes
1 answer

Do I need to delete/free dynamically allocated data (e.g. bytearray or std::vector) within a std::deque before I can call pop_back?

As far as I understand push_back() of std::deque copies the data I put in. So, when I put in reference to dynamic data (such as to a dynamic bytearray or std::vector) it copies only the reference to it. Now I try to understand if I have to…
cmax
  • 13
  • 4
0
votes
2 answers

How to append the contents of one std::queue to another

I need to be able to add (append) the contents of one std::queue to another, preferably in much the same way as using std::deque::insert, but using std::vector? I would prefer to continue using std::vectors, rather than a major rewrite to implement…
Weedware
  • 141
  • 1
  • 9
0
votes
1 answer

Abstract over deque and vector in C++ (using iterators?)

So I am writing a graph traversal routine and I would like to be able to turn it into either depth-first or breadth-first traversal by choosing a FIFO or a LIFO neighbor traversal policy. In practice this means that I need to abstract "enqueue" and…
user1411900
  • 384
  • 4
  • 14
0
votes
2 answers

Implementation of swap function for deque with constant complexity

It is said that the std::deque swap function takes constant time,not linear. http://www.cplusplus.com/reference/deque/deque/swap-free/. How is that function implemented then?
user7348782
0
votes
1 answer

How to implement circular buffer in Objective C for high performance

We want to add an array of doubles to a circular buffer in Objective C many times a second. We are currently using a NSMutableArray nested within another NSMutableArray (2D array). This works fine but is too slow for our needs. We want to add to the…
0
votes
1 answer

Avoiding std::deque iterator not dereferencable error between unmanaged c++, c++/cli and c# code

I have a VS2015 solution comprised of unmanaged c++ code (to do some CPU intensive simulation computations), a c++/cli wrapper around this code and a c# project which calls the c++/cli wrappers via a DLL. The following example is a simplified…
sjrowlinson
  • 3,297
  • 1
  • 18
  • 35
0
votes
0 answers

indy TIdtcpserver buffer limit

Is there an internal size limit of TIdtcpserver buffer? How come whatever method I use, It reaches a limit of 65535? I have encountered this buffer issue of TidTCPSever these days. My code is very basic: preset the size of buffer array, extract…