Hallo Zusammen,
ich versuche beim Einfügen eines Satzes in einer DVerkettenListe diese direkt zu sortieren, doch irgenwie mag er die Datensätze nicht an der richtigen Stelle einfügen...
weiss jemand warum?
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50:
| procedure tDVKList.Insert(myPointer: pointer); var v,n,t: tDVKListItem; tmpResult: integer; p: pointer; begin if (fAnkerAnfang = NIL) OR (count = 0) then begin add(myPointer); end else begin inc(fcount); t := tDVKListItem.create; t.Data := myPointer;
if dvklsoSortOnInsert in fSortOptions then begin p := first; while (p <> fAnkerEnde) and (p <> NIL) do begin tmpResult := fFuncSortCompare(fLauf.Data, t.data); if ((tmpResult > 0) and (dvklsoAscending in SortOptions)) or ((tmpResult < 0) and (dvklsoDesending in SortOptions)) then break; p := Next; end; end;
if fLauf = fAnkerAnfang then fLauf := fAnkerAnfang.Next; if fLauf = fAnkerEnde then fLauf := fAnkerEnde.Prior;
v := fLauf; n := fLauf.Next;
v.Next := t; t.Prior := v;
n.Prior := t; t.Next := n;
fLauf := t; end; end; |
Das Problem tritt sowohl beim auf- als auch beim absteigenden sortieren auf.
Ich find einfach die Ursache nicht
Könnt Ihr mir bitte helfen, wäre spitze
