Struct hwloc::Bitmap [] [src]

pub struct Bitmap { /* fields omitted */ }

A generic bitmap, understood by hwloc.

The Bitmap represents a set of objects, typically OS processors – which may actually be hardware threads (represented by CpuSet, which is a type alias for Bitmap – or memory nodes (represented by NodeSet, which is also a typedef for Bitmap).

Both CpuSet and NodeSet are always indexed by OS physical number.

A Bitmap may be of infinite size.

Methods

impl Bitmap
[src]

Creates an empty Bitmap.

Examples:

use hwloc::Bitmap;

let bitmap = Bitmap::new();
assert_eq!("", format!("{}", bitmap));
assert_eq!(true, bitmap.is_empty());

Creates a full Bitmap.

Examples:

use hwloc::Bitmap;

let bitmap = Bitmap::full();
assert_eq!("0-", format!("{}", bitmap));
assert_eq!(false, bitmap.is_empty());

Creates a new HwlocBitmap (either CpuSet or NodeSet) and sets one index right away.

Examples:

use hwloc::Bitmap;

let bitmap = Bitmap::from(1);
assert_eq!("1", format!("{}", bitmap));
assert_eq!(false, bitmap.is_empty());

Creates a new Bitmap with the given range.

Examples:

use hwloc::Bitmap;

let bitmap = Bitmap::from_range(0, 5);
assert_eq!("0-5", format!("{}", bitmap));

Wraps the given hwloc bitmap pointer into its Bitmap representation.

This function is not meant to be used directly, it rather serves as the conversion factory when dealing with hwloc-internal structures.

Returns the containted hwloc bitmap pointer for interaction with hwloc.

Set index id in this Bitmap.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::new();
bitmap.set(4);
assert_eq!("4", format!("{}", bitmap));

Add indexes from begin to end in this Bitmap.

If end is -1, the range is infinite.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::new();
bitmap.set_range(3, 5);
assert_eq!("3-5", format!("{}", bitmap));

bitmap.set_range(2, -1);
assert_eq!("2-", format!("{}", bitmap));

Remove index id from the Bitmap.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::from_range(1,3);
bitmap.unset(1);
assert_eq!("2-3", format!("{}", bitmap));

Remove indexes from begin to end in this Bitmap.

If end is -1, the range is infinite.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::from_range(1,5);
bitmap.unset_range(4,6);
assert_eq!("1-3", format!("{}", bitmap));

bitmap.unset_range(2,-1);
assert_eq!("1", format!("{}", bitmap));

The number of indexes that are in the bitmap.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::from_range(1,5);
assert_eq!(5, bitmap.weight());
bitmap.unset(3);
assert_eq!(4, bitmap.weight());

Clears the Bitmap.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::from_range(1,5);
assert_eq!(5, bitmap.weight());
assert_eq!(false, bitmap.is_empty());

bitmap.clear();
assert_eq!(0, bitmap.weight());
assert_eq!(true, bitmap.is_empty());

Checks if this Bitmap has indexes set.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::new();
assert_eq!(true, bitmap.is_empty());

bitmap.set(3);
assert_eq!(false, bitmap.is_empty());

bitmap.clear();
assert_eq!(true, bitmap.is_empty());

Check if the field with the given id is set.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::new();
assert_eq!(false, bitmap.is_set(2));

bitmap.set(2);
assert_eq!(true, bitmap.is_set(2));

Keep a single index among those set in the bitmap.

May be useful before binding so that the process does not have a chance of migrating between multiple logical CPUs in the original mask.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::new();
bitmap.set_range(0, 127);
assert_eq!(128, bitmap.weight());

bitmap.invert();
assert_eq!(-1, bitmap.weight());

bitmap.singlify();
assert_eq!(1, bitmap.weight());

assert_eq!(128, bitmap.first());
assert_eq!(128, bitmap.last());

Inverts the current Bitmap.

Examples:

use hwloc::Bitmap;

let mut bitmap = Bitmap::new();
bitmap.set(3);

assert_eq!("3", format!("{}", bitmap));
assert_eq!("0-2,4-", format!("{}", !bitmap));

Compute the first index (least significant bit) in this Bitmap.

Returns -1 if no index is set.

Examples:

use hwloc::Bitmap;

let bitmap = Bitmap::from_range(4,10);
assert_eq!(4, bitmap.first());

Compute the last index (most significant bit) in this Bitmap.

Returns -1 if no index is bitmap, or if the index bitmap is infinite.

Examples:

use hwloc::Bitmap;

let bitmap = Bitmap::from_range(4,10);
assert_eq!(10, bitmap.last());

Test whether this Bitmap is completely full.

Examples:

use hwloc::Bitmap;

let empty_bitmap = Bitmap::new();
assert_eq!(false, empty_bitmap.is_full());

let full_bitmap = Bitmap::full();
assert_eq!(true, full_bitmap.is_full());

Trait Implementations

impl Not for Bitmap
[src]

The resulting type after applying the ! operator

Returns a new bitmap which contains the negated values of the current one.

impl Drop for Bitmap
[src]

A method called when the value goes out of scope. Read more

impl Display for Bitmap
[src]

Formats the value using the given formatter. Read more

impl Debug for Bitmap
[src]

Formats the value using the given formatter.

impl Clone for Bitmap
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for Bitmap
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl IntoIterator for Bitmap
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

impl FromIterator<u32> for Bitmap
[src]

Creates a value from an iterator. Read more

impl Default for Bitmap
[src]

Returns the "default value" for a type. Read more