Click here to Skip to main content
15,900,258 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 9:20
sadas232341s18-Apr-11 9:20 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 9:27
professionalChris Losinger18-Apr-11 9:27 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 9:29
sadas232341s18-Apr-11 9:29 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 9:38
professionalChris Losinger18-Apr-11 9:38 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 9:39
sadas232341s18-Apr-11 9:39 
AnswerRe: Duplicates in list Pin
Luc Pattyn18-Apr-11 9:53
sitebuilderLuc Pattyn18-Apr-11 9:53 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 9:58
sadas232341s18-Apr-11 9:58 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:02
professionalChris Losinger18-Apr-11 10:02 
if you don't want to sort:
for each node, Cur
  for each node, Temp
    if Temp!=Cur
      if Temp.value==Cur.value, duplicate
    Temp=Temp.next
  Cur=Cur.next


basically, for each node, you compare its value to every other node. it's inefficient, but it will work.

you can also sort your list when you add:
1. walk the list, find the first node with a value greater than the new value. this is 'Cur'
2. change the next pointer of Cur->prev to point to your new node.
3. set your new node's prev to Cur->prev. now you're all linked in the prev direction.
4. change the prev pointer of Cur to point to your new node.
5. set your new node's cur to point to Cur. now you're all linked in the next direction.

that way, the list is always sorted, and you can just walk it, looking for duplicates.

GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:13
sadas232341s18-Apr-11 10:13 
GeneralRe: Duplicates in list Pin
David Crow18-Apr-11 18:02
David Crow18-Apr-11 18:02 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 9:54
sadas232341s18-Apr-11 9:54 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:14
professionalChris Losinger18-Apr-11 10:14 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:16
sadas232341s18-Apr-11 10:16 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:19
professionalChris Losinger18-Apr-11 10:19 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:25
sadas232341s18-Apr-11 10:25 
GeneralRe: Duplicates in list Pin
sadas232341s18-Apr-11 10:32
sadas232341s18-Apr-11 10:32 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 10:50
professionalChris Losinger18-Apr-11 10:50 
GeneralRe: Duplicates in list [modified] Pin
sadas232341s18-Apr-11 10:51
sadas232341s18-Apr-11 10:51 
GeneralRe: Duplicates in list Pin
Chris Losinger18-Apr-11 11:03
professionalChris Losinger18-Apr-11 11:03 
QuestionCritique is Need Pin
Ikeman from Moses Lake18-Apr-11 7:09
Ikeman from Moses Lake18-Apr-11 7:09 
Question[SOLVED] I need to copy (CTRL+C) a web page... C++ [modified] Pin
Ram Shmider18-Apr-11 1:43
Ram Shmider18-Apr-11 1:43 
AnswerRe: I need to copy (CTRL+C) a web page... C++ Pin
_AnsHUMAN_ 18-Apr-11 2:20
_AnsHUMAN_ 18-Apr-11 2:20 
GeneralRe: I need to copy (CTRL+C) a web page... C++ Pin
Ram Shmider19-Apr-11 20:20
Ram Shmider19-Apr-11 20:20 
AnswerRe: I need to copy (CTRL+C) a web page... C++ Pin
Nitheesh George18-Apr-11 18:27
Nitheesh George18-Apr-11 18:27 
GeneralRe: I need to copy (CTRL+C) a web page... C++ Pin
Ram Shmider19-Apr-11 20:18
Ram Shmider19-Apr-11 20:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.