vector vs map iterator

X

xyz

It's not clear at all what he does if he don't find the element.
(At one point, he says something about a "new" vector, but I'm
not sure what he's doing with it.)


I'm afraid I don't understand.  The hash table contains the
elements he's comparing against.  Depending on what he's doing
he may want to insert the element he didn't find into the hash
table, or he may not.  There's been no indication of having to
keep any sort of order (or at least, I didn't see it).

--
James Kanze (GABI Software)             email:[email protected]
Conseils en informatique orientée objet/
                   Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

I already cleared about this point in the post...

I check every incoming element the vector1...if it matches in one of
the element in the vector1 I collect the statistics...
after certain timeout the entreis get deleted...in vector1...the
timeout for every entry in the vector veries.
suppose if my entry doesnt match any of the entreis in vector1 i store
it in other vector for eg namely vector2
and these entreis i export to other module...and it does something
with those entries

as i get high timeouts my vectors are very large...so the incoming
element needs to check all those entries whether it is matched in the
vector or not..so i asked whether it is better to use vectors or
maps...
thats all...thanks everyone...
hope everyone understand....
 
J

Jim Langston

It's not clear at all what he does if he don't find the element.
(At one point, he says something about a "new" vector, but I'm
not sure what he's doing with it.)


I'm afraid I don't understand. The hash table contains the
elements he's comparing against. Depending on what he's doing
he may want to insert the element he didn't find into the hash
table, or he may not. There's been no indication of having to
keep any sort of order (or at least, I didn't see it).

--
James Kanze (GABI Software) email:[email protected]
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
-------

I already cleared about this point in the post...

I check every incoming element the vector1...if it matches in one of
the element in the vector1 I collect the statistics...
after certain timeout the entreis get deleted...in vector1...the
timeout for every entry in the vector veries.
suppose if my entry doesnt match any of the entreis in vector1 i store
it in other vector for eg namely vector2
and these entreis i export to other module...and it does something
with those entries

as i get high timeouts my vectors are very large...so the incoming
element needs to check all those entries whether it is matched in the
vector or not..so i asked whether it is better to use vectors or
maps...
thats all...thanks everyone...
hope everyone understand....

Have you followed the thread so far? You should have enough information to
decide which to at least try. Most likely you will want to try a sorted
vector, a hash map/set and see which is better for you. You have not stated
how/when entries would get added to vector1. If entries *never* get added,
the a sorted vector would definately be the way to go. Read your vector1 at
the beginning, sort it. Instead of deleting the entries after timeout,
however, I would probalby mark it as delted somehow (just so I wouldn't have
to resort my vector).

If you add entries to vector1 periodically, then maybe a sorted vector would
still be the way to go, or a binary tree (map/set/hashmap, whatever). It
depends on how often you insert entries, etc... An unsorted vector is
defintely NOT the way to go, however. Worst case scenario.
 
J

Jerry Coffin

(e-mail address removed)>, (e-mail address removed)
says...

[ ... ]
I check every incoming element the vector1...if it matches in one of
the element in the vector1 I collect the statistics...
after certain timeout the entreis get deleted...in vector1...the
timeout for every entry in the vector veries.
suppose if my entry doesnt match any of the entreis in vector1 i store
it in other vector for eg namely vector2
and these entreis i export to other module...and it does something
with those entries

as i get high timeouts my vectors are very large...so the incoming
element needs to check all those entries whether it is matched in the
vector or not..so i asked whether it is better to use vectors or
maps...

The obvious questions at this point are 1) how often do you add and
remove items from vector1 -- you've said you get a timeout, but not how
often you need to check those timeouts. From what you've said, removing
the timed-out items probably isn't a big factor in overall speed, but
it's likely to become a much larger percentage when you start to use a
binary search, so it's worthwhile to consider whether to use a vector
(where the removal will be roughly linear) or a map (where it will be
roughly logarithmic).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,276
Latest member
Sawatmakal

Latest Threads

Top