I am looking for a standard container/library in C++ with following functionalities:
- Storing the windows of numbers (enqueue and dequeue are enough).
- Returning the number of unique numbers in the window.
It can be something merging std::queue and std::set capabilities.
EDITED:
Example expected operation. For this sequence ‘1 2 3 3 4 4 5 5 6 6 7 7 8’ and window size of 2 we would have following steps:
- Window = [1 2], unique ones = 2
- Window = [2 3], unique ones = 2
- Window = [3 3], unique ones = 1
- Window = [3 4], unique ones = 2
- and so on …
You want two containers:
deque<number>to store the numbers in the window in order;map<number, size_t>(orunordered_mapif available) to store the count of each unique number.Then your operations are: