Unit Llistint |
Classes |
Functions |
Register - Published-Deklarationen
Types |
Constants |
Variables |
Functions |
Types |
CellPtr = ^TCellchange, if you want to store other data type
TCell = record
data : TData;
next : CellPtr;
prev : CellPtr;
end;
TData = integerLListint unit: doubly linked integer list-component 02.Jan.1997 V1.0} { by Alexander Wernhart, wea@felten.co.at } { This code is freeware. Please E-Mail me any cool additions, bug fixes, } { rants, raves, etc.! Thanks for trying my code, I hope it helps someone... } { based on: } { TLink unit: doubly linked lists 5/22/95} { by Jeff Atwood, JAtwood159@AOL.COM. } { } { I couldn't find a doubly-linked list implemented as an object ANYWHERE } { so I wrote it myself, after much trial, error, and poring over } { obscure programming reference books. Hey-- it's not brain surgery, but } { pointers can be so naughty. } { } { For simplicity's sake, and to keep this a one-day project, I am only } { storing simple integers in the cells. You can easily, easily change } { that to any data type supported by Delphi including records. I would } { NOT recommend trying to store a whole object with methods in there... } { I couldn't get that to work. But if you can, E-Mail me. I don't know if } { it's even possible. } { } { There is one main object, which uses the "CELL" record type for each } { entry in the list. I don't know how to hide the CELL record type from } { the user, but it should be internal to this unit. The main object is } { the TLink, which keeps track of the size, first, last, and current } { cell records. You can move around in the list by using the Move methods } { and find using the Seek method. It's all fairly straightforward, look } { at the demo form for examples, there are also comments in the code. } { } { If you're feeling ambitious, I recommend you modify the cell record to } { store pointers instead of integers. Don't forget to make copies of the } { data, because if you point to the actual location, you're screwed when } { the user destroys that instance. You gotta copy it... How many times } { did I get burned by THAT one?? Also, it would be cool to turn this into } { a VCL component, if anyone wants to do that.
Constants |
Variables |