Struct bdf::Bitmap
[−]
[src]
pub struct Bitmap { // some fields omitted }
The bitmap of a glyph.
Methods
impl Bitmap
[src]
fn new(width: u32, height: u32) -> Self
Creates a bitmap of the given size.
fn width(&self) -> u32
Gets the width.
fn height(&self) -> u32
Gets the height.
fn get(&self, x: u32, y: u32) -> bool
Gets a bit from the map.
fn set(&mut self, x: u32, y: u32, value: bool)
Sets a bit of the map.
Methods from Deref<Target=BitSet>
fn capacity(&self) -> usize
Returns the capacity in bits for this bit vector. Inserting any element less than this amount will not trigger a resizing.
Examples
use bit_set::BitSet; let mut s = BitSet::with_capacity(100); assert!(s.capacity() >= 100);
fn reserve_len(&mut self, len: usize)
Reserves capacity for the given BitSet
to contain len
distinct elements. In the case
of BitSet
this means reallocations will not occur as long as all inserted elements
are less than len
.
The collection may reserve more space to avoid frequent reallocations.
Examples
use bit_set::BitSet; let mut s = BitSet::new(); s.reserve_len(10); assert!(s.capacity() >= 10);
fn reserve_len_exact(&mut self, len: usize)
Reserves the minimum capacity for the given BitSet
to contain len
distinct elements.
In the case of BitSet
this means reallocations will not occur as long as all inserted
elements are less than len
.
Note that the allocator may give the collection more space than it requests. Therefore
capacity can not be relied upon to be precisely minimal. Prefer reserve_len
if future
insertions are expected.
Examples
use bit_set::BitSet; let mut s = BitSet::new(); s.reserve_len_exact(10); assert!(s.capacity() >= 10);
fn into_bit_vec(self) -> BitVec<B>
Consumes this set to return the underlying bit vector.
Examples
use bit_set::BitSet; let mut s = BitSet::new(); s.insert(0); s.insert(3); let bv = s.into_bit_vec(); assert!(bv[0]); assert!(bv[3]);
fn get_ref(&self) -> &BitVec<B>
Returns a reference to the underlying bit vector.
Examples
use bit_set::BitSet; let mut s = BitSet::new(); s.insert(0); let bv = s.get_ref(); assert_eq!(bv[0], true);
fn shrink_to_fit(&mut self)
Truncates the underlying vector to the least length required.
Examples
use bit_set::BitSet; let mut s = BitSet::new(); s.insert(32183231); s.remove(32183231); // Internal storage will probably be bigger than necessary println!("old capacity: {}", s.capacity()); // Now should be smaller s.shrink_to_fit(); println!("new capacity: {}", s.capacity());
fn iter(&self) -> Iter<B>
Iterator over each usize stored in the BitSet
.
Examples
use bit_set::BitSet; let s = BitSet::from_bytes(&[0b01001010]); // Print 1, 4, 6 in arbitrary order for x in s.iter() { println!("{}", x); }
fn union(&'a self, other: &'a BitSet<B>) -> Union<'a, B>
Iterator over each usize stored in self
union other
.
See union_with for an efficient in-place version.
Examples
use bit_set::BitSet; let a = BitSet::from_bytes(&[0b01101000]); let b = BitSet::from_bytes(&[0b10100000]); // Print 0, 1, 2, 4 in arbitrary order for x in a.union(&b) { println!("{}", x); }
fn intersection(&'a self, other: &'a BitSet<B>) -> Intersection<'a, B>
Iterator over each usize stored in self
intersect other
.
See intersect_with for an efficient in-place version.
Examples
use bit_set::BitSet; let a = BitSet::from_bytes(&[0b01101000]); let b = BitSet::from_bytes(&[0b10100000]); // Print 2 for x in a.intersection(&b) { println!("{}", x); }
fn difference(&'a self, other: &'a BitSet<B>) -> Difference<'a, B>
Iterator over each usize stored in the self
setminus other
.
See difference_with for an efficient in-place version.
Examples
use bit_set::BitSet; let a = BitSet::from_bytes(&[0b01101000]); let b = BitSet::from_bytes(&[0b10100000]); // Print 1, 4 in arbitrary order for x in a.difference(&b) { println!("{}", x); } // Note that difference is not symmetric, // and `b - a` means something else. // This prints 0 for x in b.difference(&a) { println!("{}", x); }
fn symmetric_difference(&'a self, other: &'a BitSet<B>) -> SymmetricDifference<'a, B>
Iterator over each usize stored in the symmetric difference of self
and other
.
See symmetric_difference_with for
an efficient in-place version.
Examples
use bit_set::BitSet; let a = BitSet::from_bytes(&[0b01101000]); let b = BitSet::from_bytes(&[0b10100000]); // Print 0, 1, 4 in arbitrary order for x in a.symmetric_difference(&b) { println!("{}", x); }
fn union_with(&mut self, other: &BitSet<B>)
Unions in-place with the specified other bit vector.
Examples
use bit_set::BitSet; let a = 0b01101000; let b = 0b10100000; let res = 0b11101000; let mut a = BitSet::from_bytes(&[a]); let b = BitSet::from_bytes(&[b]); let res = BitSet::from_bytes(&[res]); a.union_with(&b); assert_eq!(a, res);
fn intersect_with(&mut self, other: &BitSet<B>)
Intersects in-place with the specified other bit vector.
Examples
use bit_set::BitSet; let a = 0b01101000; let b = 0b10100000; let res = 0b00100000; let mut a = BitSet::from_bytes(&[a]); let b = BitSet::from_bytes(&[b]); let res = BitSet::from_bytes(&[res]); a.intersect_with(&b); assert_eq!(a, res);
fn difference_with(&mut self, other: &BitSet<B>)
Makes this bit vector the difference with the specified other bit vector in-place.
Examples
use bit_set::BitSet; let a = 0b01101000; let b = 0b10100000; let a_b = 0b01001000; // a - b let b_a = 0b10000000; // b - a let mut bva = BitSet::from_bytes(&[a]); let bvb = BitSet::from_bytes(&[b]); let bva_b = BitSet::from_bytes(&[a_b]); let bvb_a = BitSet::from_bytes(&[b_a]); bva.difference_with(&bvb); assert_eq!(bva, bva_b); let bva = BitSet::from_bytes(&[a]); let mut bvb = BitSet::from_bytes(&[b]); bvb.difference_with(&bva); assert_eq!(bvb, bvb_a);
fn symmetric_difference_with(&mut self, other: &BitSet<B>)
Makes this bit vector the symmetric difference with the specified other bit vector in-place.
Examples
use bit_set::BitSet; let a = 0b01101000; let b = 0b10100000; let res = 0b11001000; let mut a = BitSet::from_bytes(&[a]); let b = BitSet::from_bytes(&[b]); let res = BitSet::from_bytes(&[res]); a.symmetric_difference_with(&b); assert_eq!(a, res);
fn len(&self) -> usize
Returns the number of set bits in this set.
fn is_empty(&self) -> bool
Returns whether there are no bits set in this set
fn clear(&mut self)
Clears all bits in this set
fn contains(&self, value: usize) -> bool
Returns true
if this set contains the specified integer.
fn is_disjoint(&self, other: &BitSet<B>) -> bool
Returns true
if the set has no elements in common with other
.
This is equivalent to checking for an empty intersection.
fn is_subset(&self, other: &BitSet<B>) -> bool
Returns true
if the set is a subset of another.
fn is_superset(&self, other: &BitSet<B>) -> bool
Returns true
if the set is a superset of another.
fn insert(&mut self, value: usize) -> bool
Adds a value to the set. Returns true
if the value was not already
present in the set.
fn remove(&mut self, value: usize) -> bool
Removes a value from the set. Returns true
if the value was
present in the set.
Trait Implementations
impl Debug for Bitmap
[src]
impl Clone for Bitmap
[src]
fn clone(&self) -> Bitmap
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Eq for Bitmap
[src]
impl PartialEq for Bitmap
[src]
fn eq(&self, __arg_0: &Bitmap) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Bitmap) -> bool
This method tests for !=
.
impl Default for Bitmap
[src]
impl Deref for Bitmap
[src]
type Target = BitSet
The resulting type after dereferencing
fn deref(&self) -> &BitSet
The method called to dereference a value
impl DerefMut for Bitmap
[src]
fn deref_mut(&mut self) -> &mut BitSet
The method called to mutably dereference a value