@@ -261,6 +261,64 @@ impl BitSet<u32> {
261261}
262262
263263impl < B : BitBlock > BitSet < B > {
264+ /// Creates a new empty `BitSet`.
265+ ///
266+ /// # Examples
267+ ///
268+ /// ```
269+ /// use bit_set::BitSet;
270+ ///
271+ /// let mut s = <BitSet>::new_general();
272+ /// ```
273+ #[ inline]
274+ pub fn new_general ( ) -> Self {
275+ Self :: default ( )
276+ }
277+
278+ /// Creates a new `BitSet` with initially no contents, able to
279+ /// hold `nbits` elements without resizing.
280+ ///
281+ /// # Examples
282+ ///
283+ /// ```
284+ /// use bit_set::BitSet;
285+ ///
286+ /// let mut s = <BitSet>::with_capacity_general(100);
287+ /// assert!(s.capacity() >= 100);
288+ /// ```
289+ #[ inline]
290+ pub fn with_capacity_general ( nbits : usize ) -> Self {
291+ let bit_vec = BitVec :: from_elem_general ( nbits, false ) ;
292+ Self :: from_bit_vec_general ( bit_vec)
293+ }
294+
295+ /// Creates a new `BitSet` from the given bit vector.
296+ ///
297+ /// # Examples
298+ ///
299+ /// ```
300+ /// use bit_vec::BitVec;
301+ /// use bit_set::BitSet;
302+ ///
303+ /// let bv: BitVec<u64> = BitVec::from_bytes_general(&[0b01100000]);
304+ /// let s = BitSet::from_bit_vec_general(bv);
305+ ///
306+ /// // Print 1, 2 in arbitrary order
307+ /// for x in s.iter() {
308+ /// println!("{}", x);
309+ /// }
310+ /// ```
311+ #[ inline]
312+ pub fn from_bit_vec_general ( bit_vec : BitVec < B > ) -> Self {
313+ BitSet { bit_vec }
314+ }
315+
316+ pub fn from_bytes_general ( bytes : & [ u8 ] ) -> Self {
317+ BitSet {
318+ bit_vec : BitVec :: from_bytes_general ( bytes) ,
319+ }
320+ }
321+
264322 /// Returns the capacity in bits for this bit vector. Inserting any
265323 /// element less than this amount will not trigger a resizing.
266324 ///
@@ -840,6 +898,13 @@ impl<B: BitBlock> BitSet<B> {
840898 self . bit_vec . remove_all ( ) ;
841899 }
842900
901+ /// Clears all bits in this set
902+ #[ deprecated( since = "0.9.0" , note = "please use `fn make_empty` instead" ) ]
903+ #[ inline]
904+ pub fn clear ( & mut self ) {
905+ self . make_empty ( ) ;
906+ }
907+
843908 /// Returns `true` if this set contains the specified integer.
844909 #[ inline]
845910 pub fn contains ( & self , value : usize ) -> bool {
0 commit comments