Struct range_map::RangeMap [] [src]

pub struct RangeMap<T, V> {
    // some fields omitted
}

A set of characters. Optionally, each character in the set may be associated with some data.

Methods

impl<T: Debug + PrimInt, V: Clone + Debug + Eq> RangeMap<T, V>
[src]

fn new() -> RangeMap<T, V>

Creates a new empty RangeMap.

fn from_sorted_vec(vec: Vec<(Range<T>, V)>) -> RangeMap<T, V>

Creates a RangeMap from a Vec, which must contain ranges in ascending order. If any ranges overlap, they must map to the same value.

Panics if the ranges are not sorted, or if they overlap without mapping to the same value.

fn num_ranges(&self) -> usize

Returns the number of mapped ranges.

Note that this is not usually the same as the number of mapped values.

fn is_empty(&self) -> bool

Tests whether this map is empty.

fn is_full(&self) -> bool

Tests whether this CharMap maps every value.

fn ranges_values<'a>(&'a self) -> Iter<'a, (Range<T>, V)>

Iterates over all the mapped ranges and values.

fn keys_values<'a>(&'a self) -> PairIter<'a, T, V>

Iterates over all mappings.

fn get(&self, x: T) -> Option<&V>

Finds the value that x maps to, if it exists.

Runs in O(log n) time, where n is the number of mapped ranges.

fn intersection(&self, other: &RangeSet<T>) -> RangeMap<T, V>

Returns those mappings whose keys belong to the given set.

fn num_keys(&self) -> usize

Counts the number of mapped keys.

This saturates at usize::MAX.

fn to_range_set(&self) -> RangeSet<T>

Returns the set of mapped chars, forgetting what they are mapped to.

fn map_values<F>(&mut self, f: F) where F: FnMut(&V) -> V

Modifies the values in place.

fn retain_values<F>(&mut self, f: F) where F: FnMut(&V) -> bool

Modifies this map to contain only those mappings with values v satisfying f(v).

fn as_mut_slice(&mut self) -> &mut [(Range<T>, V)]

Returns a mutable view into this map.

The ranges should not be modified, since that might violate our invariants.

This method will eventually be removed, probably once anonymous return values allow is to write a values_mut() iterator more easily.

Trait Implementations

impl<T: Debug, V: Debug> Debug for RangeMap<T, V>
[src]

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>

Formats the value using the given formatter.

impl<T: Debug + PrimInt, V: Clone + Debug + Eq> FromIterator<(Range<T>, V)> for RangeMap<T, V>
[src]

fn from_iter<I: IntoIterator<Item=(Range<T>, V)>>(iter: I) -> Self

Builds a RangeMap from an iterator over pairs. If any ranges overlap, they must map to the same value.

Panics

  • if there are ranges that overlap and do not map to the same value.

Derived Implementations

impl<T: PartialEq, V: PartialEq> PartialEq for RangeMap<T, V>
[src]

fn eq(&self, __arg_0: &RangeMap<T, V>) -> bool

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

fn ne(&self, __arg_0: &RangeMap<T, V>) -> bool

This method tests for !=.

impl<T: Hash, V: Hash> Hash for RangeMap<T, V>
[src]

fn hash<__HTV: Hasher>(&self, __arg_0: &mut __HTV)

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

impl<T: Eq, V: Eq> Eq for RangeMap<T, V>
[src]

impl<T: Clone, V: Clone> Clone for RangeMap<T, V>
[src]

fn clone(&self) -> RangeMap<T, V>

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