A simple map based on a vector for small integer keys. Space requirements are O(highest integer key).

Struct SmallIntMap

pub struct SmallIntMap<T> {
    priv v: ~[Option<T>],
}

Struct SmallIntSet

pub struct SmallIntSet {
    priv map: SmallIntMap<()>,
}

A set implemented on top of the SmallIntMap type. This set is always a set of integers, and the space requirements are on the order of the highest valued integer in the set.

Implementation of Container for SmallIntMap<V> where <V>

Method len

fn len(&self) -> uint

Return the number of elements in the map

Method is_empty

fn is_empty(&self) -> bool

Return true if the map contains no elements

Implementation of Mutable for SmallIntMap<V> where <V>

Method clear

fn clear(&mut self)

Clear the map, removing all key-value pairs.

Implementation of Map<uint, V> for SmallIntMap<V> where <V>

Method contains_key

fn contains_key(&self, key: &uint) -> bool

Return true if the map contains a value for the specified key

Method find

fn find<'a>(&'a self, key: &uint) -> Option<&'a V>

Return a reference to the value corresponding to the key

Method find_mut

fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut V>

Return a mutable reference to the value corresponding to the key

Method insert

fn insert(&mut self, key: uint, value: V) -> bool

Insert a key-value pair into the map. An existing value for a key is replaced by the new value. Return true if the key did not already exist in the map.

Method remove

fn remove(&mut self, key: &uint) -> bool

Remove a key-value pair from the map. Return true if the key was present in the map, otherwise false.

Method swap

fn swap(&mut self, key: uint, value: V) -> Option<V>

Insert a key-value pair from the map. If the key already had a value present in the map, that value is returned. Otherwise None is returned.

Method pop

fn pop(&mut self, key: &uint) -> Option<V>

Removes a key from the map, returning the value at the key if the key was previously in the map.

Implementation for SmallIntMap<V> where <V>

Method new

fn new() -> SmallIntMap<V>

Create an empty SmallIntMap

Method each

fn each<'a>(&'a self, it: &fn(&uint, &'a V) -> bool) -> bool

Visit all key-value pairs in order

Method each_key

fn each_key(&self, blk: &fn(key: &uint) -> bool) -> bool

Visit all keys in order

Method each_value

fn each_value<'a>(&'a self, blk: &fn(value: &'a V) -> bool) -> bool

Visit all values in order

Method mutate_values

fn mutate_values(&mut self, it: &fn(&uint, &mut V) -> bool) -> bool

Iterate over the map and mutate the contained values

Method each_reverse

fn each_reverse<'a>(&'a self, it: &fn(uint, &'a V) -> bool) -> bool

Visit all key-value pairs in reverse order

Method get

fn get<'a>(&'a self, key: &uint) -> &'a V

Implementation for SmallIntMap<V> where <V: Copy>

Method update_with_key

fn update_with_key(&mut self, key: uint, val: V, ff: &fn(uint, V, V) -> V) ->
 bool

Method update

fn update(&mut self, key: uint, newval: V, ff: &fn(V, V) -> V) -> bool

Implementation of Container for SmallIntSet

Method len

fn len(&self) -> uint

Return the number of elements in the map

Method is_empty

fn is_empty(&self) -> bool

Return true if the map contains no elements

Implementation of Mutable for SmallIntSet

Method clear

fn clear(&mut self)

Clear the map, removing all key-value pairs.

Implementation of Set<uint> for SmallIntSet

Method contains

fn contains(&self, value: &uint) -> bool

Return true if the set contains a value

Method insert

fn insert(&mut self, value: uint) -> bool

Add a value to the set. Return true if the value was not already present in the set.

Method remove

fn remove(&mut self, value: &uint) -> bool

Remove a value from the set. Return true if the value was present in the set.

Method is_disjoint

fn is_disjoint(&self, other: &SmallIntSet) -> bool

Return true if the set has no elements in common with other. This is equivalent to checking for an empty uintersection.

Method is_subset

fn is_subset(&self, other: &SmallIntSet) -> bool

Return true if the set is a subset of another

Method is_superset

fn is_superset(&self, other: &SmallIntSet) -> bool

Return true if the set is a superset of another

Method difference

fn difference(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool

Visit the values representing the difference

Method symmetric_difference

fn symmetric_difference(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) ->
 bool

Visit the values representing the symmetric difference

Method intersection

fn intersection(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool

Visit the values representing the uintersection

Method union

fn union(&self, other: &SmallIntSet, f: &fn(&uint) -> bool) -> bool

Visit the values representing the union

Implementation for SmallIntSet

Method new

fn new() -> SmallIntSet

Create an empty SmallIntSet

Method each

fn each(&self, f: &fn(&uint) -> bool) -> bool

Visit all values in order