S
S
snk2015-10-13 12:50:36
C++ / C#
snk, 2015-10-13 12:50:36

Which stl container is best suited for this task?

Hello. The task is extremely simple: there is a certain image buffer (opencv Mat, CV_8UC3, 1920x1080). It is necessary in real time to add an element from one side, then take an element from the other side, use it and then remove it from the buffer. The buffer length can change during execution (but not often).
Now I'm using std::list. push_front to add to the beginning, back to get the last element, pop_back to remove it from the list. How effective is my choice, is there a container that is better suited for this task?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kovalsky, 2015-10-13
@dmitryKovalskiy

You have a description of the classic queue. Try queue

M
MiiNiPaa, 2015-10-13
@MiiNiPaa

Since the objects are large, the list overhead won't be noticeable. Your solution is quite effective. You can, as Dmitry Kovalsky suggests, use the queue adapter (perhaps with a list as a container if you want)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question