Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
15
Issues
15
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-platform
Commits
aaeacbbc
Verified
Commit
aaeacbbc
authored
Oct 28, 2017
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove redundant type contexts from Data.Set
parent
9df66b44
Pipeline
#8159
passed with stage
in 1 minute and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
20 deletions
+20
-20
src/libraries/OS-Independent/Data/Set.dcl
src/libraries/OS-Independent/Data/Set.dcl
+9
-9
src/libraries/OS-Independent/Data/Set.icl
src/libraries/OS-Independent/Data/Set.icl
+11
-11
No files found.
src/libraries/OS-Independent/Data/Set.dcl
View file @
aaeacbbc
...
...
@@ -68,7 +68,7 @@ size s :== case s of
/**
* Is the element in the set?
*/
member
::
!
a
!(
Set
a
)
->
Bool
|
<
a
&
==
a
member
::
!
a
!(
Set
a
)
->
Bool
|
<
a
/**
* Checks if an element is not in the set.
...
...
@@ -82,7 +82,7 @@ notMember x t :== not (member x t)
*/
isSubsetOf
t1
t2
:==
(
size
t1
<=
size
t2
)
&&
(
isSubsetOfX
t1
t2
)
isSubsetOfX
::
!(
Set
a
)
!(
Set
a
)
->
Bool
|
<
a
&
==
a
isSubsetOfX
::
!(
Set
a
)
!(
Set
a
)
->
Bool
|
<
a
/**
* Is t1 a proper subset of t2?
...
...
@@ -103,12 +103,12 @@ singleton :: !u:a -> w:(Set u:a), [w <= u]
* Insert an element in a set.
* If the set already contains an element equal to the given value, it is replaced with the new value.
*/
insert
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
&
==
a
insert
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
/**
* Delete an element from a set.
*/
delete
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
&
==
a
delete
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
/**
* The minimal element of a set.
...
...
@@ -185,13 +185,13 @@ intersections :: ![Set a] -> Set a | < a & == a
/**
* Filter all elements that satisfy the predicate.
*/
filter
::
!(
a
->
Bool
)
!(
Set
a
)
->
Set
a
|
<
a
&
==
a
filter
::
!(
a
->
Bool
)
!(
Set
a
)
->
Set
a
|
<
a
/**
* Partition the set into two sets, one with all elements that satisfy the
* predicate and one with all elements that don't satisfy the predicate.
*/
partition
::
!(
a
->
Bool
)
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
&
==
a
partition
::
!(
a
->
Bool
)
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
/**
* Split a set in elements less and elements greater than a certain pivot.
...
...
@@ -200,13 +200,13 @@ partition :: !(a -> Bool) !(Set a) -> (!Set a, !Set a) | < a & == a
* @param The set.
* @return A tuple of two sets containing small and large values.
*/
split
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
&
==
a
split
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
/**
* Performs a 'split' but also returns whether the pivot element was found in
* the original set.
*/
splitMember
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Bool
,
!
Set
a
)
|
<
a
&
==
a
splitMember
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Bool
,
!
Set
a
)
|
<
a
/**
* O(n) Post-order fold.
...
...
@@ -228,7 +228,7 @@ toAscList t :== fold (\a as -> [a:as]) [] t
/**
* Create a set from a list of elements.
*/
fromList
::
![
a
]
->
Set
a
|
<
a
&
==
a
fromList
::
![
a
]
->
Set
a
|
<
a
/**
* Map a function to all elements in a set.
...
...
src/libraries/OS-Independent/Data/Set.icl
View file @
aaeacbbc
...
...
@@ -53,7 +53,7 @@ instance < (Set a) | < a where
//size (Bin sz _ _ _) = sz
// | /O(log n)/. Is the element in the set?
member
::
!
a
!(
Set
a
)
->
Bool
|
<
a
&
==
a
member
::
!
a
!(
Set
a
)
->
Bool
|
<
a
member
x
Tip
=
False
member
x
(
Bin
_
y
l
r
)
|
x
<
y
=
member
x
l
...
...
@@ -83,14 +83,14 @@ singleton x = Bin 1 x Tip Tip
// | /O(log n)/. Insert an element in a set.
// If the set already contains an element equal to the given value,
// it is replaced with the new value.
insert
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
&
==
a
insert
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
insert
x
Tip
=
singleton
x
insert
x
(
Bin
sz
y
l
r
)
|
x
<
y
=
balanceL
y
(
insert
x
l
)
r
|
x
>
y
=
balanceR
y
l
(
insert
x
r
)
|
otherwise
=
Bin
sz
x
l
r
insertR
::
!
a
!(
Set
a
)
->
Set
a
|
<
a
&
==
a
insertR
::
!
a
!(
Set
a
)
->
Set
a
|
<
a
insertR
x
Tip
=
singleton
x
insertR
x
t
=:(
Bin
_
y
l
r
)
|
x
<
y
=
balanceL
y
(
insertR
x
l
)
r
...
...
@@ -98,7 +98,7 @@ insertR x t=:(Bin _ y l r)
|
otherwise
=
t
// | /O(log n)/. Delete an element from a set.
delete
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
&
==
a
delete
::
!
a
!.(
Set
a
)
->
Set
a
|
<
a
delete
x
Tip
=
Tip
delete
x
(
Bin
_
y
l
r
)
|
x
<
y
=
balanceR
y
(
delete
x
l
)
r
...
...
@@ -118,7 +118,7 @@ delete x (Bin _ y l r)
//isSubsetOf :: !(Set a) !(Set a) -> Bool | < a & == a
//isSubsetOf t1 t2 = (size t1 <= size t2) && (isSubsetOfX t1 t2)
isSubsetOfX
::
!(
Set
a
)
!(
Set
a
)
->
Bool
|
<
a
&
==
a
isSubsetOfX
::
!(
Set
a
)
!(
Set
a
)
->
Bool
|
<
a
isSubsetOfX
Tip
_
=
True
isSubsetOfX
_
Tip
=
False
isSubsetOfX
(
Bin
_
x
l
r
)
t
...
...
@@ -238,7 +238,7 @@ hedgeInt blo bhi (Bin _ x l r) t2
*--------------------------------------------------------------------*/
// | /O(n)/. Filter all elements that satisfy the predicate.
filter
::
!(
a
->
Bool
)
!(
Set
a
)
->
Set
a
|
<
a
&
==
a
filter
::
!(
a
->
Bool
)
!(
Set
a
)
->
Set
a
|
<
a
filter
_
Tip
=
Tip
filter
p
(
Bin
_
x
l
r
)
|
p
x
=
link
x
(
filter
p
l
)
(
filter
p
r
)
...
...
@@ -247,7 +247,7 @@ filter p (Bin _ x l r)
// | /O(n)/. Partition the set into two sets, one with all elements that satisfy
// the predicate and one with all elements that don't satisfy the predicate.
// See also 'split'.
partition
::
!(
a
->
Bool
)
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
&
==
a
partition
::
!(
a
->
Bool
)
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
partition
_
Tip
=
(
Tip
,
Tip
)
partition
p
(
Bin
_
x
l
r
)
#!
(
l1
,
l2
)
=
partition
p
l
...
...
@@ -277,10 +277,10 @@ fold f z (Bin _ x l r) = fold f (f x (fold f z r)) l
//toAscList t = fold (\a as -> [a:as]) [] t
// | /O(n*log n)/. Create a set from a list of elements.
fromList
::
![
a
]
->
Set
a
|
<
a
&
==
a
fromList
::
![
a
]
->
Set
a
|
<
a
fromList
xs
=
foldl
ins
newSet
xs
where
ins
::
!(
Set
a
)
!
a
->
Set
a
|
<
a
&
==
a
ins
::
!(
Set
a
)
!
a
->
Set
a
|
<
a
ins
t
x
=
insert
x
t
/*--------------------------------------------------------------------
...
...
@@ -354,7 +354,7 @@ filterLt (JustS b) t = filter` b t
// | /O(log n)/. The expression (@'split' x set@) is a pair @(set1,set2)@
// where @set1@ comprises the elements of @set@ less than @x@ and @set2@
// comprises the elements of @set@ greater than @x@.
split
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
&
==
a
split
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Set
a
)
|
<
a
split
_
Tip
=
(
Tip
,
Tip
)
split
x
(
Bin
_
y
l
r
)
|
x
<
y
...
...
@@ -367,7 +367,7 @@ split x (Bin _ y l r)
// | /O(log n)/. Performs a 'split' but also returns whether the pivot
// element was found in the original set.
splitMember
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Bool
,
!
Set
a
)
|
<
a
&
==
a
splitMember
::
!
a
!(
Set
a
)
->
(!
Set
a
,
!
Bool
,
!
Set
a
)
|
<
a
splitMember
_
Tip
=
(
Tip
,
False
,
Tip
)
splitMember
x
(
Bin
_
y
l
r
)
|
x
<
y
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment