1 (* Lists.def provides an unordered list manipulation package.
3 Copyright (C) 2001-2022 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 ;
27 Date : Tue Dec 12 20:53:36 EST 1989
28 SYSTEM : UNIX (GNU Modula-2)
29 Description: Provides an unordered list manipulation package.
30 Last update: $Date: 2010/10/03 19:01:05 $
31 Version : $Revision: 1.9 $
34 FROM SYSTEM IMPORT WORD ;
35 FROM SymbolKey IMPORT PerformOperation ;
37 EXPORT QUALIFIED List,
38 InitList, KillList, PutItemIntoList, GetItemFromList,
40 NoOfItemsInList, IsItemInList, IncludeItemIntoList,
41 RemoveItemFromList, ForeachItemInListDo, DuplicateList ;
48 InitList - creates a new list, l.
51 PROCEDURE InitList (VAR l: List) ;
55 KillList - deletes the complete list, l.
58 PROCEDURE KillList (VAR l: List) ;
62 PutItemIntoList - places a CARDINAL, c, into list, l.
65 PROCEDURE PutItemIntoList (l: List; c: WORD) ;
69 GetItemFromList - retrieves the nth WORD from list, l.
72 PROCEDURE GetItemFromList (l: List; n: CARDINAL) : WORD ;
76 GetIndexOfList - returns the index for WORD, c, in list, l.
77 If more than one CARDINAL, c, exists the index
78 for the first is returned.
81 PROCEDURE GetIndexOfList (l: List; c: WORD) : CARDINAL ;
85 NoOfItemsInList - returns the number of items in list, l.
88 PROCEDURE NoOfItemsInList (l: List) : CARDINAL ;
92 IncludeItemIntoList - adds a WORD, c, into a list providing
93 the value does not already exist.
96 PROCEDURE IncludeItemIntoList (l: List; c: WORD) ;
100 RemoveItemFromList - removes a WORD, c, from a list.
101 It assumes that this value only appears once.
104 PROCEDURE RemoveItemFromList (l: List; c: WORD) ;
108 IsItemInList - returns true if a WORD, c, was found in list, l.
111 PROCEDURE IsItemInList (l: List; c: WORD) : BOOLEAN ;
115 ForeachItemInListDo - calls procedure, P, foreach item in list, l.
118 PROCEDURE ForeachItemInListDo (l: List; P: PerformOperation) ;
122 DuplicateList - returns a duplicate list derived from, l.
125 PROCEDURE DuplicateList (l: List) : List ;