473,410 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

set<int> having FIFO behaviour

I have the need of a container of integers showing both the
characteristics of an associative container (all integer elements
different from each other) and the FIFO behaviour.

Do you know if there is a ready-made container for that or if I have
to use - for example - a set<int> and produce by myself FIFO
behaviour, or maybe I can use a queue<int> adding code for preventing
the insertion od duplicate integers

Thank you

Luca
Jul 19 '05 #1
4 3050

"Luca" <lc***@libero.it> wrote in message news:a9**************************@posting.google.c om...
I have the need of a container of integers showing both the
characteristics of an associative container (all integer elements
different from each other) and the FIFO behaviour.

Do you know if there is a ready-made container for that or if I have
to use - for example - a set<int> and produce by myself FIFO
behaviour, or maybe I can use a queue<int> adding code for preventing
the insertion od duplicate integers


You can't order a set other than the way implied by the comparison function
it is created with (usually Less). The easiest way is what you suggest
in the second paragraph. One easy way to check for duplication is to
use both the queue and set. Check the set prioir to insert, insert into
both if not found. Delete from the set when you delete from the queue.
Jul 19 '05 #2
In article <a9**************************@posting.google.com >,
lc***@libero.it says...
I have the need of a container of integers showing both the
characteristics of an associative container (all integer elements
different from each other) and the FIFO behaviour.


It sounds like a priority queue should work for you.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 19 '05 #3
Hi Luca!

"Luca" <lc***@libero.it> schrieb im Newsbeitrag
news:a9**************************@posting.google.c om...
I have the need of a container of integers showing both the
characteristics of an associative container (all integer elements
different from each other) and the FIFO behaviour.

Do you know if there is a ready-made container for that or if I have
to use - for example - a set<int> and produce by myself FIFO
behaviour, or maybe I can use a queue<int> adding code for preventing
the insertion od duplicate integers


Try using list as container. But there's a problem with the uniqueness. You
have to call the 'unique' method after each insert, that may result in bad
performance

HTH
Bernhard
Jul 19 '05 #4
Koenings Bernhard wrote:

Try using list as container. But there's a problem with the uniqueness. You
have to call the 'unique' method after each insert, that may result in bad
performance


I don't think that will work. 'unique' can only find duplicates that are
adjacent, implying that you must usually sort the container first. This
would destroy the existing order.

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: pmatos | last post by:
Hi all, I have a vector of vector of ints, I could use C approach by using int but I think C++ vector<vector<int> > would be easier to manage. So I have a function which creates and initializes...
19
by: Erik Wikström | last post by:
First of all, forgive me if this is the wrong place to ask this question, if it's a stupid question (it's my second week with C++), or if this is answered some place else (I've searched but not...
4
by: chrisstankevitz | last post by:
This code does not compile on gcc 3.4.4. Should it? Thanks for your help, Chris //================ #include <set> int main()
10
by: Piotr | last post by:
I have a class 'Statistics' which has a private attribute ' vector<int>* _x;' And in the destructor of the Statistics, I have this code to free the memory: Statistics::~Statistics() { if...
2
by: per9000 | last post by:
Hi, *background* I want a class containing an int (a list of sets of integer). This should be hidden for the user and he/she should be able to insert his/her favourite data structure so to be a...
8
by: per9000 | last post by:
Hi, I wanted to test to compile an application I build for .NET 2.0 in with the 1.1 C# compiler. I encountered difficulties since I had a List<myClass>. I found a list of what is new in .NET 2.0...
1
by: Monty | last post by:
I have a Usercontrol with a public property List<intLinks List <intLinks= new List<int>(); public List<intLinkLabels { get { return Links; } set { Links = value; } }
18
by: subramanian100in | last post by:
Consider a class that has vector< pair<int, string>* c; as member data object. I need to use operator>to store values into this container object and operator<< to print the contents of the...
6
by: chandramohanp | last post by:
Hi I am trying to modify class instance members using reflection. I am having problem when trying to add/remove/display elements related to List<int> member. Following is the code. class...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.