Category : Files from Magazines
Archive   : PJ94.ZIP
Filename : DLRING.ADS

 
Output of file : DLRING.ADS contained in archive : PJ94.ZIP
-- ========================= begin comment ===========================
-- dlring.ads
--
-- ******* PACKAGE SPECIFICATION ******
-- for a simple doubly-linked ring
-- data structure - partial implementation
--
-- There are many ways to implement a doubly-linked ring.
-- This listing is the Ada solution submitted by one of my
-- undergraduate computer science students. It can be improved
-- and made more reliable. Notably, the use of a counter to
-- control subprograms that traverse the ring contains some
-- potential dangers. It might be better to have a "marked"
-- node that serves as the starting and ending point for any
-- traversal algorithm. This is a good data structure on which
-- to experiment. Try to make it more efficient. Try to make it
-- more reliable. Add some additional functionality to it.
-- ========================= end of comment =========================

with TEXT_IO;
generic -- define generic formal parameters

type DLRing_Type is private;
with function EQUAL (LEFT, RIGHT : DLRing_Type) return BOOLEAN;

package DLRing is
--
type DIRECTION_TYPE is (FORWARD, BACKWARD); -- rotation
type FINGER_TYPE is limited private;

procedure ROTATE (DIRECTION : in DIRECTION_TYPE;
FINGER : in out FINGER_TYPE);

procedure INSERT (ITEM : in DLRing_Type;
FINGER : in out FINGER_TYPE);

procedure REPLACE (ITEM : in DLRing_Type;
FINGER : in out FINGER_TYPE);

procedure DELETE (FINGER : in out FINGER_TYPE;
EMPTY_ERROR : out BOOLEAN);

procedure PEEK (ITEM : out DLRing_Type;
FINGER : in out FINGER_TYPE;
EMPTY_ERROR : out BOOLEAN);

procedure SEARCH (FINGER : in out FINGER_TYPE;
ITEM : in DLRing_Type;
FOUND : out BOOLEAN);

function Is_Count (Finger : Finger_Type) return Natural;

private
type CELL; -- an incomplete type
type POINTER is access CELL; -- set up a pointer type
type FINGER_TYPE is -- keeps track of where
record -- we are in the ring
PTR : POINTER;
CNTR : NATURAL := 0;
end record;
end DLRing;
-- ++++++++++++++++ End of Package Specification ++++++++++++++++++++






  3 Responses to “Category : Files from Magazines
Archive   : PJ94.ZIP
Filename : DLRING.ADS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/