Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pike
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pikelang
pike
Commits
25c749f6
Commit
25c749f6
authored
1 month ago
by
Henrik (Grubba) Grubbström
Browse files
Options
Downloads
Plain Diff
Merge branch '9.0'
* 9.0: ADT.Set: Stricter types.
parents
51a34087
ae1a1d11
Loading
Loading
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/ADT.pmod/Set.pike
+9
-9
9 additions, 9 deletions
lib/modules/ADT.pmod/Set.pike
with
9 additions
and
9 deletions
lib/modules/ADT.pmod/Set.pike
+
9
−
9
View file @
25c749f6
...
...
@@ -82,9 +82,9 @@ array(mixed) map(function(ValueType:mixed) f)
//!
//! The filtering function is called with a single mixed-type argument
//! which is the member value to be checked.
this_program filter(function(ValueType:mixed) f)
this_program
(<ValueType>)
filter(function(ValueType:mixed) f)
{
ADT.Set result = ADT.Set();
ADT.Set
(<ValueType>)
result = ADT.Set(
<ValueType>)(
);
foreach(indices(set), ValueType item)
if (f(item))
...
...
@@ -103,7 +103,7 @@ this_program filter(function(ValueType:mixed) f)
//! @note
//! CAVEAT EMPTOR: This function was just a duplicate of @[filter()]
//! in Pike 8.0 and earlier.
this_program filter_destructively(function(ValueType:mixed) f)
this_program
(<ValueType>)
filter_destructively(function(ValueType:mixed) f)
{
foreach(indices(set), ValueType item)
if (!f(item))
...
...
@@ -128,7 +128,7 @@ int(0..1) subset(ADT.Set other)
}
//! Superset. A >= B returns true if all items in B are also present in A.
int(0..1) superset(ADT.Set other)
int(0..1) superset(ADT.Set
(<ValueType>)
other)
{
return other <= this;
}
...
...
@@ -136,7 +136,7 @@ int(0..1) superset(ADT.Set other)
//! Equality. A == B returns true if all items in A are present in B,
//! and all items in B are present in A. Otherwise, it returns false.
protected int(0..1) `==(ADT.Set other)
protected int(0..1) `==(ADT.Set
(<ValueType>)
other)
{
if (sizeof(this) != sizeof(other))
return 0;
...
...
@@ -158,7 +158,7 @@ protected int(0..1) `<(ADT.Set other)
//! True superset. A > B returns true if each item in B is also present
//! in A, and A contains at least one item not present in B.i
protected int(0..1) `>(ADT.Set other)
protected int(0..1) `>(ADT.Set
(<ValueType>)
other)
{
if (sizeof(this) <= sizeof(other))
return 0;
...
...
@@ -170,7 +170,7 @@ protected int(0..1) `>(ADT.Set other)
//! or both of the operand sets.
protected this_program(<mixed>) `|(ADT.Set(<mixed>) other)
{
ADT.Set result = ADT.Set(this);
ADT.Set
(<mixed>)
result = ADT.Set(
<mixed>)(
this);
foreach(indices(other), mixed item)
result->add(item);
...
...
@@ -183,7 +183,7 @@ protected mixed `+ = `|; // Addition on sets works the same as union on sets.
//! Intersection. Returns a set containing those values that were
//! present in both the operand sets.
protected this_program
`&(ADT.Set
other)
protected this_program
(<ValueType>) `&(ADT.Set(<ValueType>)
other)
{
return filter(lambda (ValueType x) { return other->contains(x);});
}
...
...
@@ -191,7 +191,7 @@ protected this_program `&(ADT.Set other)
//! Difference. The expression 'A - B', where A and B are sets, returns
//! all elements in A that are not also present in B.
protected this_program
`-(ADT.Set
other)
protected this_program
(<ValueType>) `-(ADT.Set(<ValueType>)
other)
{
return filter(lambda (ValueType x) { return !other->contains(x);});
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment