1 (* lists.def Provides an unordered list manipulation package.
3 Copyright (C) 2015-2024 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
22 DEFINITION MODULE lists ;
24 FROM SYSTEM IMPORT ADDRESS ;
25 FROM symbolKey IMPORT performOperation ;
32 initList - creates a new list, l.
35 PROCEDURE initList () : list ;
39 killList - deletes the complete list, l.
42 PROCEDURE killList (VAR l: list) ;
46 putItemIntoList - places an ADDRESS, c, into list, l.
49 PROCEDURE putItemIntoList (l: list; c: ADDRESS) ;
53 getItemFromList - retrieves the nth ADDRESS from list, l.
56 PROCEDURE getItemFromList (l: list; n: CARDINAL) : ADDRESS ;
60 getIndexOfList - returns the index for ADDRESS, c, in list, l.
61 If more than one CARDINAL, c, exists the index
62 for the first is returned.
65 PROCEDURE getIndexOfList (l: list; c: ADDRESS) : CARDINAL ;
69 noOfItemsInList - returns the number of items in list, l.
72 PROCEDURE noOfItemsInList (l: list) : CARDINAL ;
76 includeItemIntoList - adds an ADDRESS, c, into a list providing
77 the value does not already exist.
80 PROCEDURE includeItemIntoList (l: list; c: ADDRESS) ;
84 removeItemFromList - removes an ADDRESS, c, from a list.
85 It assumes that this value only appears once.
88 PROCEDURE removeItemFromList (l: list; c: ADDRESS) ;
92 isItemInList - returns true if a ADDRESS, c, was found in list, l.
95 PROCEDURE isItemInList (l: list; c: ADDRESS) : BOOLEAN ;
99 foreachItemInListDo - calls procedure, P, foreach item in list, l.
102 PROCEDURE foreachItemInListDo (l: list; p: performOperation) ;
106 duplicateList - returns a duplicate list derived from, l.
109 PROCEDURE duplicateList (l: list) : list ;