1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
-- File: EntityCluster.cdl
-- Created: Mon Nov 2 16:03:55 1992
-- Author: Christian CAILLET
-- <cky@topsn2>
---Copyright: Matra Datavision 1992
private class EntityCluster from Interface inherits TShared
---Purpose : Auxiliary class for EntityList. An EntityList designates an
-- EntityCluster, which brings itself an fixed maximum count of
-- Entities. If it is full, it gives access to another cluster
-- ("Next"). This class is intended to give a good compromise
-- between access time (faster than a Sequence, good for little
-- count) and memory use (better than a Sequence in any case,
-- overall for little count, better than an Array for a very
-- little count. It is designed for a light management.
-- Remark that a new Item may not be Null, because this is the
-- criterium used for "End of List"
uses EntityIterator, Transient
raises OutOfRange, NullObject
is
Create returns mutable EntityCluster;
---Purpose : Creates an empty, non-chained, EntityCluster
Create (ent : any Transient) returns mutable EntityCluster;
---Purpose : Creates a non-chained EntityCluster, filled with one Entity
Create (ec : mutable EntityCluster) returns mutable EntityCluster;
---Purpose : Creates an empty EntityCluster, chained with another one
-- (that is, put BEFORE this other one in the list)
Create (ant : any Transient; ec : mutable EntityCluster)
returns mutable EntityCluster;
---Purpose : Creates an EntityCluster, filled with a first Entity, and
-- chained to another EntityCluster (BEFORE it, as above)
Append (me : mutable; ent : any Transient)
---Purpose : Appends an Entity to the Cluster. If it is not full, adds the
-- entity directly inside itself. Else, transmits to its Next
-- and Creates it if it does not yet exist
raises NullObject is static;
-- Error if <ent> is Null
Remove (me : mutable; ent : any Transient) returns Boolean
---Purpose : Removes an Entity from the Cluster. If it is not found, calls
-- its Next one to do so.
-- Returns True if it becomes itself empty, False else
-- (thus, a Cluster which becomes empty is deleted from the list)
raises NullObject is static;
-- Error if <ent> is Null
Remove (me : mutable; num : Integer) returns Boolean
---Purpose : Removes an Entity from the Cluster, given its rank. If <num>
-- is greater than NbLocal, calls its Next with (num - NbLocal),
-- Returns True if it becomes itself empty, False else
raises OutOfRange is static;
-- Raises an Exception if there is no Next to do so.
NbEntities (me) returns Integer is static;
---Purpose : Returns total count of Entities (including Next)
Value (me; num : Integer) returns any Transient
---Purpose : Returns the Entity identified by its rank in the list
-- (including Next)
raises OutOfRange is static;
-- Error if num less than 1 or num more then NbEntities
---C++ : return const &
SetValue (me : mutable; num : Integer; ent : any Transient)
---Purpose : Changes an Entity given its rank.
raises OutOfRange, NullObject is static;
-- Error if <num> is not in [1 - NbEntities], or if <ent> is Null
FillIterator (me; iter : in out EntityIterator) is static;
---Purpose : Fills an Iterator with designated Entities (includes Next)
-- -- Internal Queries, also used by EntityList -- --
IsLocalFull (me) returns Boolean is static private;
---Purpose : Returns True if all the set of entities local to a Cluster is
-- full. Used by EntityList.
NbLocal (me) returns Integer is static private;
---Purpose : Returns count of entities in the local set (without Next)
-- Entities can then be read normally by method Value
HasNext (me) returns Boolean is static private;
---Purpose : Returns True if a Cluster has a Next
Next (me) returns mutable EntityCluster is static private;
---Purpose : Returns Next Cluster in the chain
fields
theents : Transient[4]; -- 4 : best compromise for memory use
thenext : EntityCluster;
friends
class EntityList -- of which EntityCluster stores content
end EntityCluster;
|