home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
PASCAL
/
FLXLIST.ZIP
/
FLEXLIST.INT
< prev
next >
Wrap
Text File
|
1990-03-05
|
4KB
|
132 lines
{
flexlist.pas
3-5-90
Generic hybrid stack-queue-list-array object.
Copyright 1990
John W. Small
All rights reserved
PSW / Power SoftWare
P.O. Box 10072
McLean, Virginia 22102 8072
This software is offered a shareware, meaning try before
you buy. If you find it useful and are using it in your
applications a registration fee of $14 is required! Upon
registration you will be sent source code along with the
latest example programs on a DOS formatted 5 1/4" disk.
Run flexlist.dem, the demo program, while studying this
source code to gain the most rapid understanding of
FlexList!
Anytime your Turbo Pascal 5.5 application requires a
stack, queue, or linked list, simply include "flexlist"
in its "uses" clause. Next declare your stack, queue,
or list as a variable of type "Flist". Flist, a
flexlist object, is really a generic hybrid
stack-queue-list-array data structure. Your Flist
variable can be initialized to store any type of data.
The Flist object has 31 methods for accessing your
"list" as a stack, queue, list, or array
interchangeably! You can push, pop, insert, delete,
sort, store, recall, or find to name but just a few
operations. The complement of Flist methods allows you
to access your list's data by value (copy) or by
reference (pointer) as well as to move nodes directly
between lists. And your application's code size won't
continue to grow when you add new types of lists either,
since the Flist object is generic, able to hold any type
of data, record or object. Since FlexLists are
initialized at run time, the data they hold or even
their creation can be specified at run time thus
allowing your application new dimensions of adaptibility
to user specifications. And with FlexList you can
quickly construct lists of lists or other composite
structures. FlexList will save you time, money, code
space and headaches!
For example:
type myStackItem = integer;
var myStack : Flist;
begin
writeln('Count backwards from ten by pushing 1 to 10');
writeln('onto the stack and then popping and displaying');
writeln('the results.');
myStack.init(sizeof(myStackItem));
for i := 1 to 10 do
myStack.push(i);
myStack.pop(i);
while myStack.ok do begin
writeln(i);
myStack.pop(i)
end
write('Press ''Enter'' to quit.');
readln
end.
}
unit flexlist;
interface
type
FlistData = word;
FlistN = ^FlistNode;
FlistNode = record
next, prev : FlistN;
data : FlistData
end;
FlistTest = function (var buf1, buf2) : integer;
FlistH = ^Flist;
Flist = object
front, current, rear : FlistN;
curNum, nodes, dataSize : word;
ok : boolean;
constructor init(dataLen : word);
constructor unpack(cellLen, cells : word; var arrayBuf);
procedure clr;
procedure push(var buf);
procedure pushN(n : FlistN);
procedure pop(var buf);
function popN : FlistN;
procedure top(var buf);
function frontD : pointer;
procedure insertQ(var buf);
procedure insertQN(n : FlistN);
function rearD : pointer;
procedure mkcur(i : word);
function currentD : pointer;
procedure insert(var buf);
procedure insertN(n : FlistN);
procedure insertSort(var buf; test : FlistTest);
procedure insertSortN(n : FlistN; test : FlistTest);
procedure delete(var buf);
function deleteN : FlistN;
function next(var buf) : boolean;
function nextD(var d : pointer) : boolean;
function prev(var buf) : boolean;
function prevD(var d : pointer) : boolean;
procedure get(var buf);
procedure put(var buf);
procedure store(var buf; location : word);
procedure recall(var buf; location : word);
function find(var buf; test : FlistTest) : boolean;
procedure sort(test : FlistTest);
function pack : pointer;
function packPtrs : pointer;
destructor done; virtual;
end;