From d10d8d6ab8b7bc89c53e05ef7a52a831d49d0e20 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 20 Jun 2021 17:32:52 -0700 Subject: [PATCH] bitset: add from with length func Allowing to reconstruct a bitset from the outputs of Len() and Bytes(). Signed-off-by: Christian Stewart --- bitset.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bitset.go b/bitset.go index d688806..7f2fe50 100644 --- a/bitset.go +++ b/bitset.go @@ -89,7 +89,12 @@ func (b *BitSet) safeSet() []uint64 { // From is a constructor used to create a BitSet from an array of integers func From(buf []uint64) *BitSet { - return &BitSet{uint(len(buf)) * 64, buf} + return FromWithLength(uint(len(buf))*64, buf) +} + +// FromWithLength constructs from an array of integers and length. +func FromWithLength(len uint, set []uint64) *BitSet { + return &BitSet{len, set} } // Bytes returns the bitset as array of integers