1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef GLK_ALAN3_SET
24 #define GLK_ALAN3_SET
25 
26 /* Abstract datatype Set for Alan interpreter
27 
28     A set is implemented as a struct holding a size and a
29     dynamically allocated array of members. Members can be
30     integers or instance numbers. Attributes of Set type is
31     allocated and the pointer to it is used as the attribute
32     value. As members are only references, clearing a set can
33     simply be done by setting the size to zero.
34 */
35 
36 #include "glk/alan3/acode.h"
37 #include "glk/alan3/types.h"
38 
39 namespace Glk {
40 namespace Alan3 {
41 
42 struct Set {
43 	int size;
44 	int allocated;
45 	Aword *members;
46 };
47 
48 extern Set *newSet(int size);
49 extern void initSets(SetInitEntry *initTable);
50 extern int setSize(Set *theSet);
51 extern void clearSet(Set *theSet);
52 extern Set *copySet(Set *theSet);
53 extern Aword getSetMember(Set *theSet, Aint member);
54 extern bool inSet(Set *theSet, Aword member);
55 extern void addToSet(Set *theSet, Aword newMember);
56 extern void removeFromSet(Set *theSet, Aword member);
57 extern Set *setUnion(Set *theSet, Set *other);
58 extern bool equalSets(Set *theSet, Set *other);
59 extern void freeSet(Set *theSet);
60 
61 } // End of namespace Alan3
62 } // End of namespace Glk
63 
64 #endif
65