1,006 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
1
answer
144
views
Getting the same result -> hot potato game in C using Deque
I’m currently learning about data structures and algorithms (DSA) by reading the book "Learning JavaScript Data Structures and Algorithms – 2nd Edition" by Loiane Groner. I am implementing the DSAs in ...
0
votes
0
answers
105
views
List-like data structure to prepend in O(1) faster than deque
I'm looking for a Deque like data structure, but it's only responsible for prepending to the start in O(1) time. Since it wouldn't need to append to the end, it would simplify the responsibilities ...
0
votes
1
answer
102
views
Serial Real Time Plotter python
The code below plots numbers received from serial port. However, the values of locals()[self.axes_mapping[axis]] are not all the received data from the function receive_data. It seems some values are ...
0
votes
1
answer
106
views
Implement thread safe deque
As part of a server application to run on macOS, I need to implement a thread-safe deque in order to feed jobs to a thread pool. I'm new to Swift.
In C++ it would look like:
class JobQueue
{
public:
...
4
votes
1
answer
473
views
How to find the longest increasing subsequence in a circular buffer?
I am trying to solve a sorting problem in which it would be useful to determine the longest increasing subsequence in a circular buffer.
As an example, let's take the following sequence:
5, 3, 4, 2, 1
...
0
votes
3
answers
200
views
Does a deque maintain its capacity even if emptied completely?
I wanted to test if a deque<> does free its chunks if it is completely emptied:
#include <iostream>
#include <deque>
using namespace std;
uint64_t nAllocs = 0, nFrees = 0;
void *...
3
votes
0
answers
150
views
How do I pass a head-tail linked list to a function immutably?
If I need to pass a reference to an int immutably, I can pass it as a const int* to a function, as opposed to int*. This also helps the interface show that the pointed data won't be mutated.
Now I ...
1
vote
0
answers
450
views
Why does each Block in the MSVC implementation of std::deque have only 16 bytes? Can I modify it?
I learned this fact after reading Inside STL: The deque, implementation, and I am very shocked by it. 16 bytes!? That’s only twice the size of a pointer! I know that the major implementations of the ...
許恩嘉's user avatar
- 1,331
0
votes
0
answers
37
views
Objects with distinct values are writen to a deque but when reading them all but the first have the same value (involving Poisson Sampling)
This code creates a client class with variables name, arrival time, and delay. The loop creates new clients in a queue by reading their arrival time, adding a delay to it, and make it the arrival for ...
1
vote
1
answer
56
views
Generalizing a function for matrices of different types (e.g., deque of vectors, array of vectors, and vice versa)
I have created a version that works for vectors, but I am currently at a standstill regarding how to adapt it to work with other types of matrices. I don't know if I should, and if I can give the ...
3
votes
0
answers
201
views
Bug when sorting std::deque
When compiling a C++ project in release mode with Visual Studio 2022 version 17.6.4 with the ‘Inline function expansion’ option set to /Ob2, i have found out that the std::sort() function for std::...
0
votes
0
answers
30
views
How to fix TypeError: 'int' object is not subscriptable error in deques, python
I am trying to code Round Robin scheduling algorithm in python3.10. But I kept getting this
error, when i try to access elements of each list inside deque self.__ready_queue:
Traceback (most recent ...
1
vote
0
answers
62
views
Can iterator of `std::deque` go before its beginning [duplicate]
Is code like the following guaranteed to work, or is there undefined behavior?
#include <deque>
#include <cassert>
int main() {
std::deque<int> arr{1, 2, 3};
auto it = arr....
tmlen's user avatar
- 9,242
0
votes
0
answers
25
views
Python: Deque Unable to load specific number of rows from bottom of csv while including the 1st row header column names
CSV has 8000 rows. The code needs to pick up "n" rows (example: 1500) from the bottom of the csv, along with the header column names.
The data from csv looks like this:
Ticker
Name
Date
Open
...
2
votes
0
answers
62
views
Why do mutable borrow errors disappear when refining the type of a function pointer variable
In my function I need to rotate a VecDeque a certain amount of times, always in the same direction that depends on the input, with a value that never changes. So I started envisioning a solution like ...