Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Spot
Spot
Commits
ec83e60b
Commit
ec83e60b
authored
Nov 22, 2016
by
Etienne Renault
Browse files
bitvec: remove useless methods
* spot/misc/bitvect.hh, tests/core/bitvect.cc, tests/core/bitvect.test: here.
parent
43ec36cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
spot/misc/bitvect.hh
View file @
ec83e60b
...
...
@@ -140,50 +140,6 @@ namespace spot
return
(
size_
+
bpb
-
1
)
/
bpb
;
}
/// Append one bit.
void
emplace_back
(
bool
val
)
{
if
(
size
()
==
capacity
())
grow
();
size_t
pos
=
size_
++
;
if
(
val
)
set
(
pos
);
else
clear
(
pos
);
}
/// \brief Append the lowest \a count bits of \a data.
void
emplace_back
(
block_t
data
,
unsigned
count
)
{
if
(
size
()
+
count
>
capacity
())
grow
();
const
size_t
bpb
=
8
*
sizeof
(
block_t
);
// Clear the higher bits.
if
(
count
!=
bpb
)
data
&=
(
1UL
<<
count
)
-
1
;
size_t
n
=
size
()
%
bpb
;
size_t
i
=
size_
/
bpb
;
size_
+=
count
;
if
(
n
==
0
)
// Aligned on block_t boundary
{
storage_
[
i
]
=
data
;
}
else
// Only (bpb-n) bits free in this block.
{
// Take the lower bpb-n bits of data...
block_t
mask
=
(
1UL
<<
(
bpb
-
n
))
-
1
;
block_t
data1
=
(
data
&
mask
)
<<
n
;
mask
<<=
n
;
// ... write them on the higher bpb-n bits of last block.
storage_
[
i
]
=
(
storage_
[
i
]
&
~
mask
)
|
data1
;
// Write the remaining bits in the next block.
if
(
bpb
-
n
<
count
)
storage_
[
i
+
1
]
=
data
>>
(
bpb
-
n
);
}
}
size_t
size
()
const
{
return
size_
;
...
...
@@ -392,57 +348,6 @@ namespace spot
return
!
(
other
<
*
this
);
}
// \brief Extract a range of bits.
//
// Build a new bit-vector using the bits from \a begin (included)
// to \a end (excluded).
bitvect
*
extract_range
(
size_t
begin
,
size_t
end
)
{
SPOT_ASSERT
(
begin
<=
end
);
SPOT_ASSERT
(
end
<=
size
());
size_t
count
=
end
-
begin
;
bitvect
*
res
=
make_bitvect
(
count
);
res
->
make_empty
();
if
(
end
==
begin
)
return
res
;
const
size_t
bpb
=
8
*
sizeof
(
bitvect
::
block_t
);
size_t
indexb
=
begin
/
bpb
;
unsigned
bitb
=
begin
%
bpb
;
size_t
indexe
=
(
end
-
1
)
/
bpb
;
if
(
indexb
==
indexe
)
{
block_t
data
=
storage_
[
indexb
];
data
>>=
bitb
;
res
->
emplace_back
(
data
,
count
);
}
else
{
block_t
data
=
storage_
[
indexb
];
data
>>=
bitb
;
res
->
emplace_back
(
data
,
bpb
-
bitb
);
count
-=
bpb
-
bitb
;
while
(
count
>=
bpb
)
{
++
indexb
;
res
->
emplace_back
(
storage_
[
indexb
],
bpb
);
count
-=
bpb
;
SPOT_ASSERT
(
indexb
!=
indexe
||
count
==
0
);
}
if
(
count
>
0
)
{
++
indexb
;
SPOT_ASSERT
(
indexb
==
indexe
);
SPOT_ASSERT
(
count
==
end
%
bpb
);
res
->
emplace_back
(
storage_
[
indexb
],
count
);
}
}
return
res
;
}
friend
SPOT_API
bitvect
*
make_bitvect
(
size_t
bitcount
);
/// Print a bitvect.
...
...
tests/core/bitvect.cc
View file @
ec83e60b
...
...
@@ -67,37 +67,6 @@ int main()
std
::
cout
<<
"subset? "
<<
w
->
is_subset_of
(
*
x
)
<<
' '
<<
v
->
is_subset_of
(
*
w
)
<<
'\n'
;
for
(
size_t
i
=
0
;
i
<
30
;
++
i
)
w
->
emplace_back
((
i
&
3
)
==
0
);
ECHO
(
w
);
*
x
&=
*
w
;
ECHO
(
x
);
x
->
set_all
();
ECHO
(
x
);
ruler
();
w
->
emplace_back
(
0x09
,
4
);
ECHO
(
w
);
spot
::
bitvect
*
y
=
w
->
extract_range
(
0
,
71
);
ECHO
(
y
);
delete
y
;
y
=
w
->
extract_range
(
0
,
64
);
ECHO
(
y
);
delete
y
;
y
=
w
->
extract_range
(
64
,
75
);
ECHO
(
y
);
delete
y
;
y
=
w
->
extract_range
(
0
,
75
);
ECHO
(
y
);
delete
y
;
y
=
w
->
extract_range
(
7
,
64
);
ECHO
(
y
);
delete
y
;
y
=
w
->
extract_range
(
7
,
72
);
ECHO
(
y
);
delete
y
;
delete
v
;
delete
w
;
delete
x
;
...
...
@@ -115,8 +84,6 @@ int main()
ruler
();
for
(
size_t
i
=
0
;
i
<
12
;
++
i
)
a
->
at
(
4
).
emplace_back
((
i
&
2
)
==
0
);
a
->
at
(
6
)
=
a
->
at
(
4
);
a
->
at
(
8
)
=
a
->
at
(
7
);
a
->
at
(
6
)
^=
a
->
at
(
8
);
...
...
tests/core/bitvect.test
View file @
ec83e60b
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2013, 2015 Laboratoire de Recherche et Développement
# Copyright (C) 2013, 2015
, 2016
Laboratoire de Recherche et Développement
# de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
...
...
@@ -44,20 +44,6 @@ w: 000000000010110000000000000000100000000001
x
:
000000000000000000000000000000000000000000000000000000000000100000000010000
x
:
000000000010110000000000000000100000000001000000000000000000100000000010000
subset
?
1
0
w
:
000000000010110000000000000000100000000001100010001000100010001000100010
x
:
000000000010110000000000000000100000000001000000000000000000000000000010000
x
:
111111111111111111111111111111111111111111111111111111111111111111111111111
0_________1_________2_________3_________4_________5_________6_________7_____
01234567
89012345678901234567890123456789012345678901234567890123456789012345
w
:
0000000000101100000000000000001000000000011000100010001000100010001000101001
y
:
00000000001011000000000000000010000000000110001000100010001000100010001
y
:
0000000000101100000000000000001000000000011000100010001000100010
y
:
00100010100
y
:
000000000010110000000000000000100000000001100010001000100010001000100010100
y
:
000101100000000000000001000000000011000100010001000100010
y
:
00010110000000000000000100000000001100010001000100010001000100010
0_________1_________2_________3_________4_________5_________6_________7_____
01234567
89012345678901234567890123456789012345678901234567890123456789012345
...
...
@@ -80,13 +66,13 @@ y: 00010110000000000000000100000000001100010001000100010001000100010
1
:
110011001100110011001100110011001100110011001100110011001100
2
:
001100110011001100110011001100110011001100110011001100110011
3
:
001100110011001100110011001100110011001100110011001100110011
4
:
110011001100110011001100110011001100110011001100110011001100
110011001100
4
:
110011001100110011001100110011001100110011001100110011001100
5
:
110011001100110011001100110011001100110011001100110011001100
6
:
111111111111111111111111111111111111111111111111111111111111
110011001100
6
:
111111111111111111111111111111111111111111111111111111111111
7
:
001100110011001100110011001100110011001100110011001100110011
8
:
001100110011001100110011001100110011001100110011001100110011
9
:
110011001100110011001100110011001100110011001100110011001100
Comp
:
10110
1
0
Comp
:
10110
0
0
EOF
diff
expected
stderr
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment