A double-ended queue. Container datatype which is typically supporting efficient insertion and removal from two ends.
Questions tagged [deque]
993 questions
-2
votes
2 answers
Why can't I access the size of this C++ array?
I am new to C++, and I am trying to write a function to solve this challenge. The code I have looks like this:
#include
#include
#include
using namespace std;
void printKMax(int arr[], int n, int k){
deque…

adam tropp
- 674
- 7
- 22
-2
votes
3 answers
Average of last 6 elements from given element in list
I have list=[307, 258, 164, 193, 174, 285, 230, 160, 257, 306, 173, 169, 192, 209, 110]
I want to calculate average last 6 elements from given element[n] in list and after that n should iterate by 1[n+1] and again same operation should…

trupti
- 11
- 1
-2
votes
1 answer
Convert deque to Json
I have a server that reveives a set of data like this :
['Date(yyyy - mm - dd)', 'Time', 'Conductivity(mS / cm)', 'Temperature(C)', 'Depth(m)', 'Battery(V)', 'Salinity(PSU)', 'Density (kg m-3)', 'Calc, SV (m/s)']
['18/01/2017', '08:04,3', '12,217',…

Ahmed kharroubi
- 13
- 3
-2
votes
1 answer
Double Linked Queue with specific template
I have the intention to do a program based on a Double Linked Deque where nodes have double links and what i want to do is that each node is a "Document with name and priority" (priority = 1 insert from head, prio. = 2 insert from rear).
Actually…

Arnau Martínez
- 33
- 1
- 1
- 3
-2
votes
2 answers
I'm implementing a deque using singly linked list in Java. My addLast() is not working
I'm implementing a deque using singly linked list in Java. My addFirst() function is working fine, but addLast() is not working.
Whenever I call addLast(), I got the following error message:
java.lang.NullPointerException

Zhengxi Tan
- 23
- 2
- 6
-2
votes
1 answer
Need an understanding on deque
I do not understand how for d[5] the answer is C. I am trying to understand lists in C++ but for some reason this concept escapes me. Can anyone explain why C is the correct answer?
The following represents output from the call d.Dump() from…

CS Studentzzz
- 77
- 8
-2
votes
2 answers
Fastest way to add a deque onto the end of a vector?
This question is about speed.
I am using a function in the openCV libraries (in FaceRecognizer class) which requires the input of a vector. I need to build this vector by combining several deque. Are there any faster ways other than iterating…

wprins
- 846
- 2
- 19
- 35
-2
votes
2 answers
Null pointer exception while dequeing Queue in java
My dequeue method :
public T deQueue(){
if(isempty()){
System.out.println("Queue is empty, cant dequeue");
}else if(front==rear){
T value=queue[front];
front=-1;
rear=-1;
…

Arun Prakash
- 913
- 2
- 8
- 11
-2
votes
2 answers
Dequeue class printing address instead of QueueNode item
I'm trying to create a Linked List dequeue class that accepts nodes at the head as well as rear. My method, tailRemove() should remove only the item at the tail of the deque. However, when I print it, it's printing the address. The toString() method…

srsarkar7
- 155
- 5
- 19
-2
votes
1 answer
Memory fault in C++ program seemingly caused by deque
I am building a small C++ program that needs to use a deque to manage some dynamic data. I built the script and works great when there are small amounts of data put in and taken out of the deque, but when a good amount of data is put in and out the…

chromedude
- 4,246
- 16
- 65
- 96
-2
votes
3 answers
Is this valid when dereferencing an iterator
for (auto iter = dlQueue.cbegin(); iter != dlQueue.cend(); ++iter)
{
// reference to the current element in the container
if (*iter.id == listid)
{
*iter.stall =…

TheBlueCat
- 1,147
- 5
- 19
- 38
-2
votes
1 answer
deque prints back element instead of the front using front()
I am using dque to push some elements that I read from a file to the back of the deque but when I print them from the front I only get the last element
fgets(line,100,file);
qu.push_back(line);
fgets(line,100,file);
qu.push_back(line);
…

Roola
- 137
- 1
- 7
-2
votes
2 answers
comparison between pointers
I am implementing a dequeue in c via arrays. left and right are pointers which point to the leftmost and rightmost elements of the dequeue. The show() function recieves the left and right pointers. When i try the following in void show(int *l,int…

ksb
- 670
- 8
- 19
-3
votes
1 answer
implementation of dequeue in python using linkedlist
I implemented a Dequeue using a simple list in python. However i need to implement a separate class for linked list and implement dequeue with that. For this pointer reference is needed at left and right ends. I don't know how to do this. Can some…

kiran
- 51
- 1
- 1
- 6
-3
votes
1 answer
deque implementation details
I am reading article about the implementation of deque(Deques)
Here is the corresponding code:
template
class deque
{
public:
⋮
private:
size_type theSize;
T** blockmap;
size_type mapSize;
…

Vardan Hovhannisyan
- 1,101
- 3
- 17
- 40