Browse Prior Art Database

Simple LIST Implementation

IP.com Disclosure Number: IPCOM000039699D
Original Publication Date: 1987-Jul-01
Included in the Prior Art Database: 2005-Feb-01
Document File: 6 page(s) / 21K

Publishing Venue

IBM

Related People

Griffiths, LK: AUTHOR

Abstract

In order to handle a LIST of elements, the LIST operations must be able to manipulate elements to a limited degree. Specifically, some LIST operations must be able to COPY an element to place it into the list or to retrieve it from the list or must be able to COMPARE elements to see if they are in the list. If an element is itself a structure which is chained together with pointers, then merely copying or comparing the anchor block will not be good enough. A fully generic list implementation would be able (at the price of extra complexity for the user) to overcome these restrictions. This simple implementation treats the elements as CHAR(*) fields. The user must be aware of when this is not appropriate.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 26% of the total text.

Page 1 of 6

Simple LIST Implementation

In order to handle a LIST of elements, the LIST operations must be able to manipulate elements to a limited degree. Specifically, some LIST operations must be able to COPY an element to place it into the list or to retrieve it from the list or must be able to COMPARE elements to see if they are in the list. If an element is itself a structure which is chained together with pointers, then merely copying or comparing the anchor block will not be good enough. A fully generic list implementation would be able (at the price of extra complexity for the user) to overcome these restrictions. This simple implementation treats the elements as CHAR(*) fields. The user must be aware of when this is not appropriate. For instance, instead of using the operation SLINDEXC to search for an element, he might have to use the SLDOP/SLODP macros to construct a search loop of his own. Declaring an SL Each procedure that uses any SL macros must contain one (and only one) invocation of the SLX macro. Failure to include this will give many spurious diagnostics (mainly due to missing declarations for structures and constants). ?SLX; Enable use of SL data type ?SLDCL(N); Declare N as an AUTOMATIC SL. Initialize N to EMPTY.

The storage of the list will NOT be

automatically reclaimed at block exit unless the

list is first made EMPTY. If the list is not

empty at block exit storage will be permanently

lost. ?SLPDCL(N); Declare N as an SL PARAMETER. No initialization is performed. ?SLSDCL(N); Declare N as a STATIC SL initialized to EMPTY. ?SLTYPE(N); Declare N as a BASED SL. This can be used for deferred typing as it allows DCL 1 OTHER LIKE N; ?SLINCL(N); Declare a list in the middle of an existing structure. No initialization is performed.

SLINIT should be used to initialize the list to empty.

(SLCLEAR cannot be used for this purpose).

A sample block is

DCL 1 MYBLOCK BASED

, 2 SUBBLOCK

, 5 ?SLINCL(LIST1);

, 5 XXX BIN(31)

, 2 ?SLINCL(LIST2);

; ?SLINIT(N); Initialize the list to EMPTY and valid.

This should only be used in conjunction with SLINCL.

Other declaration macros include appropriate initializa

tion. ?SLCURDCL(C);Declare C as a cursor for marking positions in an SL. Building/Altering a List. ?SLADDL(L,E,LE); Add the element E of length LE to the left-hand end

of the list L.

1

Page 2 of 6

If not enough storage is available then L acquires

invalid status, but is otherwise unchanged. ?SLADDLC(L,E); This gives the same function as ADDL for the case

when it is legal to apply the LENGTH built-in function

to E to obtain its length. ?SLADDR(L,E,LE);

Add the element E of length LE to the right-hand end

of the list L. The contents of E are copied into the list.

If not enough storage is available, then L acquires

invalid status, but is otherwise unchanged. ?SLADDRC(L,E); This gives the same function as ADDR for the case

when it is legal to apply the LENGTH built-in function

to E to obtain its length. ?SLADDRS(L,P,LE);

This is similar to AD...