Struct shawshank::StadiumSet [] [src]

pub struct StadiumSet<O: StableAddress<Target = R>, R: ?Sized + StableAddress = <O as Deref>::Target, I = usize, M = HashMap<&'static <R as Deref>::Target, I>>(pub ArenaSet<O, I, M>);

Specialization of ArenaSet where O::Target: StableAddress.

Example: if O = Arc<Vec<u8>>, then O::Target = Vec<u8>. Therefore, the map M can be HashMap<&'static u8, usize>, rather than the HashMap<&'static Vec<u8>, usize> that ArenaSet would use. intern can similarly accept &'a [u8] instead of &'a Vec<u8>.

Methods

impl<O, R, I, M> StadiumSet<O, R, I, M> where
    O: StableAddress<Target = R>,
    R: 'static + StableAddress,
    I: Copy + ToPrimitive + FromPrimitive + Bounded,
    M: Map<Key = &'static <R as Deref>::Target, Value = I>, 
[src]

Analogue of intern.

use std::collections::HashMap;
use std::sync::Arc;

let mut p = shawshank::byte_stadium_set();
assert_eq!(p.intern(&[1,2,3][..]), Ok(0));
assert_eq!(p.intern(vec![1,2,3]), Ok(0));

Analogue of disintern.

use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;

let mut p = shawshank::byte_stadium_set();
assert_eq!(p.intern(&[1,2,3][..]), Ok(0));
assert_eq!(p.disintern(0).unwrap().deref().deref(), &[1,2,3]);

Analogue of resolve.

use std::collections::HashMap;
use std::sync::Arc;

let mut p = shawshank::byte_stadium_set();
assert_eq!(p.intern(&[1,2,3][..]), Ok(0));
let s1: &Vec<u8> = p.resolve(0).unwrap();
let s1: &Arc<Vec<u8>> = p.resolve(0).unwrap();

Analogue of shrink.