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
d11e1c14
Commit
d11e1c14
authored
Feb 3, 2021
by
Chris
Browse files
Options
Downloads
Patches
Plain Diff
Add len operator for BSet + minor fixes.
parent
b9858f2e
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
btypes_primitives/src/main/python/btypes/BSet.py
+5
-3
5 additions, 3 deletions
btypes_primitives/src/main/python/btypes/BSet.py
with
5 additions
and
3 deletions
btypes_primitives/src/main/python/btypes/BSet.py
+
5
−
3
View file @
d11e1c14
...
@@ -4,7 +4,6 @@ from btypes.BString import *
...
@@ -4,7 +4,6 @@ from btypes.BString import *
from
btypes.BStruct
import
*
from
btypes.BStruct
import
*
class
BSet
:
class
BSet
:
def
__init__
(
self
,
*
args
):
def
__init__
(
self
,
*
args
):
...
@@ -28,6 +27,9 @@ class BSet:
...
@@ -28,6 +27,9 @@ class BSet:
def
__ne__
(
self
,
other
):
def
__ne__
(
self
,
other
):
return
not
self
.
__eq__
(
other
)
return
not
self
.
__eq__
(
other
)
def
__len__
(
self
):
return
len
(
self
.
__set
)
def
union
(
self
,
other
=
None
):
def
union
(
self
,
other
=
None
):
if
other
is
None
:
if
other
is
None
:
if
len
(
self
.
__set
)
==
0
:
if
len
(
self
.
__set
)
==
0
:
...
@@ -112,7 +114,7 @@ class BSet:
...
@@ -112,7 +114,7 @@ class BSet:
start
=
BSet
()
start
=
BSet
()
queue
=
[
start
]
queue
=
[
start
]
result
=
result
.
union
(
BSet
(
start
))
result
=
result
.
union
(
BSet
(
start
))
while
not
len
(
queue
)
==
0
:
while
not
(
len
(
queue
)
==
0
)
:
currentSet
=
queue
.
pop
()
currentSet
=
queue
.
pop
()
for
element
in
self
.
__set
:
for
element
in
self
.
__set
:
nextSet
=
currentSet
.
union
(
BSet
(
element
))
nextSet
=
currentSet
.
union
(
BSet
(
element
))
...
@@ -245,5 +247,5 @@ class BSet:
...
@@ -245,5 +247,5 @@ class BSet:
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
__set
)
return
iter
(
self
.
__set
)
#Import is at the bottom due to cyclic dependencies
from
btypes.BRelation
import
*
from
btypes.BRelation
import
*
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