]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | (* Sets.def provides a dynamic set module. |
2 | ||
83ffe9cd | 3 | Copyright (C) 2009-2023 Free Software Foundation, Inc. |
1eee94d3 GM |
4 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. |
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 Sets ; | |
23 | ||
24 | (* | |
25 | Title : Sets | |
26 | Author : Gaius Mulley | |
27 | System : GNU Modula-2 | |
28 | Date : Wed May 6 22:48:19 2009 | |
29 | Revision : $Version$ | |
30 | Description: provides a dynamic set module which allows | |
31 | sets to contain the elements in the range: | |
32 | min..SymbolTable.FinalSymbol() | |
33 | *) | |
34 | ||
35 | FROM SymbolKey IMPORT PerformOperation ; | |
36 | ||
37 | EXPORT QUALIFIED Set, | |
38 | InitSet, KillSet, | |
39 | IncludeElementIntoSet, ExcludeElementFromSet, | |
40 | NoOfElementsInSet, IsElementInSet, | |
41 | ForeachElementInSetDo, DuplicateSet ; | |
42 | ||
43 | TYPE | |
44 | Set ; | |
45 | ||
46 | ||
47 | (* | |
48 | InitSet - initializes and returns a set. The set will | |
49 | never contain an element less than, low. | |
50 | *) | |
51 | ||
52 | PROCEDURE InitSet (low: CARDINAL) : Set ; | |
53 | ||
54 | ||
55 | (* | |
56 | KillSet - deallocates Set, s. | |
57 | *) | |
58 | ||
59 | PROCEDURE KillSet (s: Set) : Set ; | |
60 | ||
61 | ||
62 | (* | |
63 | DuplicateSet - returns a new duplicated set. | |
64 | *) | |
65 | ||
66 | PROCEDURE DuplicateSet (s: Set) : Set ; | |
67 | ||
68 | ||
69 | (* | |
70 | ForeachElementInSetDo - for each element e in, s, call, p(e). | |
71 | *) | |
72 | ||
73 | PROCEDURE ForeachElementInSetDo (s: Set; p: PerformOperation) ; | |
74 | ||
75 | ||
76 | (* | |
77 | IsElementInSet - returns TRUE if element, i, is in set, s. | |
78 | *) | |
79 | ||
80 | PROCEDURE IsElementInSet (s: Set; i: CARDINAL) : BOOLEAN ; | |
81 | ||
82 | ||
83 | (* | |
84 | NoOfElementsInSet - returns the number of elements in a set, s. | |
85 | *) | |
86 | ||
87 | PROCEDURE NoOfElementsInSet (s: Set) : CARDINAL ; | |
88 | ||
89 | ||
90 | (* | |
91 | ExcludeElementFromSet - excludes element, i, from set, s. | |
92 | *) | |
93 | ||
94 | PROCEDURE ExcludeElementFromSet (s: Set; i: CARDINAL) ; | |
95 | ||
96 | ||
97 | (* | |
98 | IncludeElementIntoSet - includes element, i, into set, s. | |
99 | *) | |
100 | ||
101 | PROCEDURE IncludeElementIntoSet (s: Set; i: CARDINAL) ; | |
102 | ||
103 | ||
104 | END Sets. |