Deleting sub-list from list

C

Crimarc

A list with un-sorted members
Along with a sub-list of that list with also un-sorted members
Could you tell me how to delete the sub-list members present in the
given list without first sorting their members ??

Thank you
Crimarc
 
M

Mike Wahler

Crimarc said:
A list with un-sorted members
Along with a sub-list of that list with also un-sorted members
Could you tell me how to delete the sub-list members present in the
given list without first sorting their members ??

No sorting needed.

Iterate through your sub-list from beginning to end;
for each element, look it up in your 'main' list (e.g.
with 'std::find()'), and delete it.

-Mike
 
C

Crimarc

Mike Wahler said:
Iterate through your sub-list from beginning to end;
for each element, look it up in your 'main' list (e.g.
with 'std::find()'), and delete it.

-Mike
Thanks Mike,
Would you please try to think up some other methods ? I don't know
what other ways I can do, true!
What you suggested takes lots of time for my program to run if my list
is in a file of over i.e 1oo,ooo KB.

Crimark
 
K

Karl Heinz Buchegger

Crimarc said:
Thanks Mike,
Would you please try to think up some other methods ? I don't know
what other ways I can do, true!
What you suggested takes lots of time for my program to run if my list
is in a file of over i.e 1oo,ooo KB.

IMHO there is no better method with the given environment.
If you want something faster: sort it or change your data
structure.
 

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

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top