Skip to content

Commit

Permalink
Added some files in Server version/Sources & Documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard94 committed Mar 31, 2018
1 parent e27439e commit 5f14246
Show file tree
Hide file tree
Showing 8 changed files with 249 additions and 265 deletions.
Binary file modified Server version/Blackbox/Util/Docu/Sets.odc
Binary file not shown.
Binary file modified Server version/Blackbox/Util/Mod/Sets.odc
Binary file not shown.
91 changes: 54 additions & 37 deletions Server version/Documentation/Util/Sets.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,21 @@ DEFINITION UtilSets;
(s1: Set) Diff (s2: Set): Set, NEW;
(s1: Set) XOR (s2: Set): Set, NEW;
(s: Set) In (e: INTEGER): BOOLEAN, NEW;
(s: Set) NbOfElems (): INTEGER, NEW;
(s: Set) IsEmpty (): BOOLEAN, NEW;
(s1: Set) Equal (s2: Set): BOOLEAN, NEW;
(s1: Set) Subset (s2: Set): BOOLEAN, NEW;
(s: Set) NextElem (inc: BOOLEAN; VAR e: INTEGER): BOOLEAN, NEW;
(s: Set) FirstE (OUT e: INTEGER): BOOLEAN, NEW;
(s: Set) NextE (OUT e: INTEGER): BOOLEAN, NEW;
(s: Set) First (OUT min, max: INTEGER): BOOLEAN, NEW;
(s: Set) Next (OUT min, max: INTEGER): BOOLEAN, NEW;
(s: Set) Copy (): Set, NEW
END;

SetIterator = RECORD
(VAR i: SetIterator) Attach (s: Set), NEW;
(VAR i: SetIterator) First (OUT min, max: INTEGER): BOOLEAN, NEW;
(VAR i: SetIterator) Next (OUT min, max: INTEGER): BOOLEAN, NEW;
(VAR i: SetIterator) FirstE (OUT e: INTEGER): BOOLEAN, NEW;
(VAR i: SetIterator) NextE (OUT e: INTEGER): BOOLEAN, NEW
END;

PROCEDURE NewSet (): Set;

END UtilSets.
Expand All @@ -54,113 +57,127 @@ Number of elements in the set.

PROCEDURE (s: Set) Empty
NEW
Empties the set s.
Empty the set s.

PROCEDURE (s: Set) Full
NEW
Returns in s the largest set available: sMin..sMax.
Returnsin s the largest set available: sMin..sMax.

PROCEDURE (s: Set) Interval (min, max: INTEGER)
NEW
Sets s to the interval min..max.
Set s to the interval min..max.

Pre
min..max is included in sMin..sMax 20

PROCEDURE (s: Set) Clear (min, max: INTEGER)
NEW
Removes the interval min..max from the set s.
Remove the interval min..max from the set s.

PROCEDURE (s: Set) Fill (min, max: INTEGER)
NEW
Adds the interval min..max to the set s.
Add the interval min..max to the set s.

PROCEDURE (s: Set) Incl (e: INTEGER)
NEW
Includes the integer e in the set s.
Include the integer e in the set s.

PROCEDURE (s: Set) Excl (e: INTEGER)
NEW
Excludes the integer e from the set s.
Exclude the integer e from the set s.

PROCEDURE (s: Set) Small (se: SET)
NEW
Sets s to the Component Pascal SET se.
Set s to the Component Pascal SET se.

PROCEDURE (s1: Set) Union (s2: Set): Set
NEW
Returns the union of s1 and s2.
Return the union of s1 and s2.

Pre
s2 # NIL 20

PROCEDURE (s1: Set) Inter (s2: Set): Set
NEW
Returns the intersection of s1 and s2.
Return the intersection of s1 and s2.

Pre
s2 # NIL 20

PROCEDURE (s1: Set) Diff (s2: Set): Set
NEW
Returns the difference between s1 and s2.
Return the difference between s1 and s2.

Pre
s2 # NIL 20

PROCEDURE (s1: Set) XOR (s2: Set): Set
NEW
Returns the exclusive union of s1 and s2.
Return the exclusive union of s1 and s2.

Pre
s2 # NIL 20

PROCEDURE (s: Set) In (e: INTEGER): BOOLEAN
NEW
Tests whether the integer e is in the set s.

PROCEDURE (s: Set) NbOfElems (): INTEGER
NEW
Returns the number of elements in s.
Check whether the integer e is in the set s.

PROCEDURE (s: Set) IsEmpty (): BOOLEAN
NEW
Tests whether s is empty.
Check whether s is empty.

PROCEDURE (s1: Set) Equal (s2: Set): BOOLEAN
NEW
Tests whether s1 = s2.
Check whether s1 = s2.

PROCEDURE (s1: Set) Subset (s2: Set): BOOLEAN
NEW
Tests whether s1 is a subset (in the broad sense of the word) of s2.
Check whether s1 is a subset (in the broad sense of the word) of s2.

PROCEDURE (s: Set) NextElem (inc: BOOLEAN; VAR e: INTEGER): BOOLEAN
NEW
Replaces e by the next integer e' of s. If inc = TRUE, e' > e; otherwise, e' < e. e may be outside of the interval sMin..sMax, but e' is inside it. Returns TRUE if there is such a successor of e, otherwise e is unchanged. Usage: e := sMin - 1; WHILE s.NextElem(TRUE, e) DO ... END;
Replace e by the next integer e' of s. If inc = TRUE, e' > e; otherwise, e' < e. e may be outside of the interval sMin..sMax, but e' is inside it. Return TRUE if there is such a successor of e, otherwise e is unchanged. Usage: e := sMin - 1; WHILE s.NextElem(TRUE, e) DO ... END;

PROCEDURE (s: Set) FirstE (OUT e: INTEGER): BOOLEAN
PROCEDURE (s: Set) Copy (): Set
NEW
On return, e contains the first integer of the set s. Returns TRUE if such an integer exists. Usage: ok := s.FirstE(e); WHILE ok DO ... ok := s.NextE(e) END;. Using FirstE & NextE works faster than using NextElem.
Create and return a copy of s.

TYPE SetIterator
Iterator of a Set..

PROCEDURE (VAR i: SetIterator) Attach (s: Set), NEW;
Attach the set s to i..

PROCEDURE (s: Set) NextE (OUT e: INTEGER): BOOLEAN
PROCEDURE (VAR i: SetIterator) First (OUT min, max: INTEGER): BOOLEAN
NEW
On return, e contains the next integer of the set s. Returns TRUE if such an integer exists. s.FirstE must have been called once before s.NextE. Usage: ok := s.FirstE(e); WHILE ok DO ... ok := s.NextE(e) END;. Using FirstE & NextE works faster than using NextElem.
On return, min and max contain the first interval of the set attached to i. Return TRUE if such an interval exists. Usage: ok := i.First(a, b); WHILE ok DO ... ok := s.Next(a, b) END;

PROCEDURE (s: Set) First (OUT min, max: INTEGER): BOOLEAN
Pre
i has been attached to a Set 20
i.First was called once before 21

PROCEDURE (VAR i: SetIterator) Next (OUT min, max: INTEGER): BOOLEAN
NEW
On return, min and max contain the first interval of the set s. Returns TRUE if such an interval exists. Usage: ok := s.First(a, b); WHILE ok DO ... ok := s.Next(a, b) END;
On return, min and max contain the next interval of the set attached to i. Returns TRUE if such an interval exists. i.First must have been called once before i.Next. Usage: ok := i.First(a, b); WHILE ok DO ... ok := i.Next(a, b) END;

Pre
i has been attached to a Set 20
i.First was called once before 21

PROCEDURE (s: Set) Next (OUT min, max: INTEGER): BOOLEAN
PROCEDURE (VAR i: SetIterator) FirstE (OUT e: INTEGER): BOOLEAN
NEW
On return, min and max contain the next interval of the set s. Returns TRUE if such an interval exists. s.First must have been called once before s.Next. Usage: ok := s.First(a, b); WHILE ok DO ... ok := s.Next(a, b) END;
On return, e contains the first integer of the set attached to i. Return TRUE if such an integer exists. Usage: ok := i.FirstE(e); WHILE ok DO ... ok := i.NextE(e) END;. Using FirstE & NextE works faster than using NextElem.

Pre
s.First was called once before 20
i has been attached to a Set 20

PROCEDURE (s: Set) Copy (): Set
PROCEDURE (VAR i: SetIterator) NextE (OUT e: INTEGER): BOOLEAN
NEW
Creates and returns a copy of s.
On return, e contains the next integer of the set attached to i. Return TRUE if such an integer exists. i.FirstE must have been called once before i.NextE. Usage: ok := i.FirstE(e); WHILE ok DO ... ok := i.NextE(e) END;. Using FirstE & NextE works faster than using NextElem.

Pre
i has been attached to a Set 20
i.First was called once before 21

PROCEDURE NewSet (): Set
Creates and returns a new empty set.
Loading

0 comments on commit 5f14246

Please sign in to comment.