Skip to content

Commit c7c8eb5

Browse files
authored
make bit vector a vector (#42)
* make bit vector a vector * fix tests
1 parent b3cf8dc commit c7c8eb5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/bitvector.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ julia> ev[2]
1616
0x0000000000000002
1717
```
1818
"""
19-
struct StaticElementVector{N,S,C}
19+
struct StaticElementVector{N,S,C} <: AbstractVector{UInt64}
2020
data::NTuple{C,UInt64}
2121
end
2222

2323
Base.length(::StaticElementVector{N,S,C}) where {N,S,C} = N
24+
Base.size(::StaticElementVector{N,S,C}) where {N,S,C} = (N,)
2425
Base.:(==)(x::StaticElementVector, y::AbstractVector) = [x...] == [y...]
2526
Base.:(==)(x::AbstractVector, y::StaticElementVector) = [x...] == [y...]
2627
Base.:(==)(x::StaticElementVector{N,S,C}, y::StaticElementVector{N,S,C}) where {N,S,C} = x.data == y.data
@@ -137,6 +138,7 @@ function Base.iterate(x::StaticElementVector{N,S,C}, state=1) where {N,S,C}
137138
end
138139

139140
Base.show(io::IO, t::StaticElementVector) = Base.print(io, "$(join(Int.(t), ""))")
141+
Base.show(io::IO, ::MIME"text/plain", t::StaticElementVector) = Base.show(io, t)
140142

141143
function Base.count_ones(x::StaticBitVector)
142144
sum(v->count_ones(v),x.data)
@@ -166,4 +168,4 @@ function parse_vector(nflavor::Int, str::String)
166168
end
167169
end
168170
return StaticElementVector(nflavor, val)
169-
end
171+
end

0 commit comments

Comments
 (0)