Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
b2program
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
general
stups
b2program
Commits
929914e6
Commit
929914e6
authored
3 years ago
by
Cookiebowser
Browse files
Options
Downloads
Patches
Plain Diff
lazy_op progress
parent
91e86bdc
Branches
Branches containing commit
No related tags found
1 merge request
!28
Rust support
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
btypes_lazy/src/main/rust/btypes/src/bset.rs
+12
-0
12 additions, 0 deletions
btypes_lazy/src/main/rust/btypes/src/bset.rs
btypes_lazy/src/main/rust/btypes/src/lazy_ops/set_ops/setops.rs
+70
-12
70 additions, 12 deletions
..._lazy/src/main/rust/btypes/src/lazy_ops/set_ops/setops.rs
with
82 additions
and
12 deletions
btypes_lazy/src/main/rust/btypes/src/bset.rs
+
12
−
0
View file @
929914e6
...
...
@@ -37,6 +37,10 @@ pub struct BSet<T: BObject> {
transformation
:
Option
<
Box
<
dyn
SetOp
<
Item
=
T
>>>
,
}
impl
<
T
:
BObject
>
BSet
<
T
>
{
const
OP_NAME
:
&
'static
str
=
"set"
;
}
impl
<
T
:
BObject
>
SetOp
for
BSet
<
T
>
{
type
Item
=
T
;
...
...
@@ -50,6 +54,14 @@ impl<T: BObject> SetOp for BSet<T> {
fn
clone_box
(
&
self
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
{
todo!
()
}
fn
get_op_name
(
&
self
)
->
&
str
{
return
BSet
::
<
T
>
::
OP_NAME
;
}
fn
get_rhs
(
&
self
)
->
Option
<&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>>
{
return
self
.transformation
.as_ref
();
}
}
impl
<
T
:
BObject
>
SetOpTraits
for
BSet
<
T
>
{
...
...
This diff is collapsed.
Click to expand it.
btypes_lazy/src/main/rust/btypes/src/lazy_ops/set_ops/setops.rs
+
70
−
12
View file @
929914e6
...
...
@@ -11,17 +11,63 @@ pub trait SetOp: SetOpTraits + Debug {
fn
compute
(
&
self
,
lhs
:
&
BSet
<
Self
::
Item
>
)
->
BSet
<
Self
::
Item
>
;
fn
clone_box
(
&
self
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
;
fn
get_op_name
(
&
self
)
->
&
str
;
fn
get_rhs
(
&
self
)
->
Option
<&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>>
;
//PartialEq
fn
eq
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
bool
;
fn
eq_box
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
bool
{
self
.get_op_name
()
.eq
(
other
.get_op_name
())
&&
self
.get_rhs
()
.eq
(
&
other
.get_rhs
())
}
//PartialOrd
fn
partial_cmp
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Option
<
Ordering
>
;
fn
partial_cmp_box
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Option
<
Ordering
>
{
let
mut
result
=
self
.get_op_name
()
.partial_cmp
(
other
.get_op_name
());
if
result
.is_some
()
{
if
result
.clone
()
.unwrap
()
.eq
(
&
Ordering
::
Equal
)
{
result
=
self
.get_rhs
()
.partial_cmp
(
&
other
.get_rhs
());
}
}
return
result
;
}
//Ord
fn
cmp
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Ordering
;
fn
max
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
;
fn
min
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
;
fn
clamp
(
&
self
,
min
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
,
max
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
;
fn
cmp_box
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Ordering
{
let
mut
result
=
self
.get_op_name
()
.cmp
(
other
.get_op_name
());
if
result
.eq
(
&
Ordering
::
Equal
)
{
result
=
self
.get_rhs
()
.cmp
(
&
other
.get_rhs
());
}
return
result
;
}
fn
lt
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
bool
{
self
.cmp_box
(
other
)
.eq
(
&
Ordering
::
Less
)
}
fn
le
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
bool
{
[
Ordering
::
Less
,
Ordering
::
Equal
]
.contains
(
&
self
.cmp_box
(
other
))
}
fn
gt
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
bool
{
self
.cmp_box
(
other
)
.eq
(
&
Ordering
::
Greater
)
}
fn
ge
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
bool
{
[
Ordering
::
Greater
,
Ordering
::
Equal
]
.contains
(
&
self
.cmp_box
(
other
))
}
fn
max
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
{
match
self
.cmp_box
(
other
)
{
Ordering
::
Less
=>
other
.clone
(),
Ordering
::
Equal
=>
other
.clone
(),
Ordering
::
Greater
=>
self
.clone_box
(),
}
}
fn
min
(
&
self
,
other
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
{
match
self
.cmp_box
(
other
)
{
Ordering
::
Less
=>
self
.clone_box
(),
Ordering
::
Equal
=>
self
.clone_box
(),
Ordering
::
Greater
=>
other
.clone
(),
}
}
fn
clamp
(
&
self
,
min
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
,
max
:
&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
{
if
self
.lt
(
min
)
{
return
min
.clone
()
}
else
if
self
.gt
(
max
)
{
max
.clone
()
}
else
{
self
.clone_box
()
}
}
}
pub
trait
SetOpTraits
{
...
...
@@ -49,28 +95,28 @@ impl<T: BObject> Eq for Box<dyn SetOp<Item=T>> {}
impl
<
T
:
BObject
>
PartialEq
<
Self
>
for
Box
<
dyn
SetOp
<
Item
=
T
>>
{
fn
eq
(
&
self
,
other
:
&
Self
)
->
bool
{
self
.eq
(
other
)
self
.eq
_box
(
other
)
}
}
impl
<
T
:
BObject
>
PartialOrd
<
Self
>
for
Box
<
dyn
SetOp
<
Item
=
T
>>
{
fn
partial_cmp
(
&
self
,
other
:
&
Self
)
->
Option
<
Ordering
>
{
self
.partial_cmp
(
other
)
self
.partial_cmp
_box
(
other
)
}
}
impl
<
T
:
BObject
>
Ord
for
Box
<
dyn
SetOp
<
Item
=
T
>>
{
fn
cmp
(
&
self
,
other
:
&
Self
)
->
Ordering
{
self
.cmp
(
other
)
self
.cmp
_box
(
other
)
}
}
impl
<
T
:
'static
+
BObject
>
dyn
SetOp
<
Item
=
T
>
{
/*
impl<T: 'static + BObject>
Default for Box<
dyn SetOp<Item = T>
>
{
fn default() -> Box<Self> {
Box::new(Identity {phantom: PhantomData})
}
}
*/
...
...
@@ -81,6 +127,10 @@ pub struct Identity<T: BObject> {
phantom
:
PhantomData
<
T
>
,
}
impl
<
T
:
BObject
>
Identity
<
T
>
{
const
OP_NAME
:
&
'static
str
=
"Identity"
;
}
impl
<
T
:
BObject
>
Debug
for
Identity
<
T
>
{
fn
fmt
(
&
self
,
f
:
&
mut
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"Identity()"
)
...
...
@@ -97,6 +147,14 @@ impl<T: 'static + BObject> SetOp for Identity<T> {
fn
clone_box
(
&
self
)
->
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>
{
Box
::
new
(
Identity
{
phantom
:
PhantomData
})
}
fn
get_op_name
(
&
self
)
->
&
str
{
return
Identity
::
<
T
>
::
OP_NAME
;
}
fn
get_rhs
(
&
self
)
->
Option
<&
Box
<
dyn
SetOp
<
Item
=
Self
::
Item
>>>
{
return
Option
::
None
;
}
}
impl
<
T
:
'static
+
BObject
>
SetOpTraits
for
Identity
<
T
>
{}
\ No newline at end of file
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