| 1 |
(* wlists.def word lists module. |
| 2 |
|
| 3 |
Copyright (C) 2015-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 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) |
| 11 |
any later version. |
| 12 |
|
| 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. |
| 17 |
|
| 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/>. *) |
| 21 |
|
| 22 |
DEFINITION MODULE wlists ; |
| 23 |
|
| 24 |
|
| 25 |
FROM SYSTEM IMPORT WORD ; |
| 26 |
|
| 27 |
TYPE |
| 28 |
wlist ; |
| 29 |
performOperation = PROCEDURE (WORD) ; |
| 30 |
|
| 31 |
|
| 32 |
(* |
| 33 |
initList - creates a new wlist, l. |
| 34 |
*) |
| 35 |
|
| 36 |
PROCEDURE initList () : wlist ; |
| 37 |
|
| 38 |
|
| 39 |
(* |
| 40 |
killList - deletes the complete wlist, l. |
| 41 |
*) |
| 42 |
|
| 43 |
PROCEDURE killList (VAR l: wlist) ; |
| 44 |
|
| 45 |
|
| 46 |
(* |
| 47 |
putItemIntoList - places an WORD, c, into wlist, l. |
| 48 |
*) |
| 49 |
|
| 50 |
PROCEDURE putItemIntoList (l: wlist; c: WORD) ; |
| 51 |
|
| 52 |
|
| 53 |
(* |
| 54 |
getItemFromList - retrieves the nth WORD from wlist, l. |
| 55 |
*) |
| 56 |
|
| 57 |
PROCEDURE getItemFromList (l: wlist; n: CARDINAL) : WORD ; |
| 58 |
|
| 59 |
|
| 60 |
(* |
| 61 |
getIndexOfList - returns the index for WORD, c, in wlist, l. |
| 62 |
If more than one CARDINAL, c, exists the index |
| 63 |
for the first is returned. |
| 64 |
*) |
| 65 |
|
| 66 |
PROCEDURE getIndexOfList (l: wlist; c: WORD) : CARDINAL ; |
| 67 |
|
| 68 |
|
| 69 |
(* |
| 70 |
noOfItemsInList - returns the number of items in wlist, l. |
| 71 |
*) |
| 72 |
|
| 73 |
PROCEDURE noOfItemsInList (l: wlist) : CARDINAL ; |
| 74 |
|
| 75 |
|
| 76 |
(* |
| 77 |
includeItemIntoList - adds an WORD, c, into a wlist providing |
| 78 |
the value does not already exist. |
| 79 |
*) |
| 80 |
|
| 81 |
PROCEDURE includeItemIntoList (l: wlist; c: WORD) ; |
| 82 |
|
| 83 |
|
| 84 |
(* |
| 85 |
removeItemFromList - removes an WORD, c, from a wlist. |
| 86 |
It assumes that this value only appears once. |
| 87 |
*) |
| 88 |
|
| 89 |
PROCEDURE removeItemFromList (l: wlist; c: WORD) ; |
| 90 |
|
| 91 |
|
| 92 |
(* |
| 93 |
replaceItemInList - replace the nth WORD in wlist, l. |
| 94 |
The first item in a wlists is at index, 1. |
| 95 |
If the index, n, is out of range nothing is changed. |
| 96 |
*) |
| 97 |
|
| 98 |
PROCEDURE replaceItemInList (l: wlist; n: CARDINAL; w: WORD) ; |
| 99 |
|
| 100 |
|
| 101 |
(* |
| 102 |
isItemInList - returns true if a WORD, c, was found in wlist, l. |
| 103 |
*) |
| 104 |
|
| 105 |
PROCEDURE isItemInList (l: wlist; c: WORD) : BOOLEAN ; |
| 106 |
|
| 107 |
|
| 108 |
(* |
| 109 |
foreachItemInListDo - calls procedure, P, foreach item in wlist, l. |
| 110 |
*) |
| 111 |
|
| 112 |
PROCEDURE foreachItemInListDo (l: wlist; p: performOperation) ; |
| 113 |
|
| 114 |
|
| 115 |
(* |
| 116 |
duplicateList - returns a duplicate wlist derived from, l. |
| 117 |
*) |
| 118 |
|
| 119 |
PROCEDURE duplicateList (l: wlist) : wlist ; |
| 120 |
|
| 121 |
|
| 122 |
END wlists. |