[−][src]Enum weighted_random_list::Entry
Update or insert one entry inside the the list.
Variants
Vacant
Fields of Vacant
arena: &'container mut WeightedRandomList<T>
needle: T
Occupied
Fields of Occupied
arena: &'container mut WeightedRandomList<T>
index: usize
Methods
impl<'container, T> Entry<'container, T>
[src]
pub fn set_weight(&mut self, new_weight: usize)
[src]
Panics if Entry
is Vacant
let mut l = WeightedRandomList::new(); l.push(12, 42); let mut element = l.entry_first(&42).or_insert_with_weight(10); element.set_weight(100);
pub fn or_insert_with_weight(self, weight: usize) -> Self
[src]
Inserts if Entry
is Vacant
.
Does nothing if found inside the list.
let mut l = WeightedRandomList::new(); // add 42 with weight 10 l.entry_first(&42).or_insert_with_weight(10);
pub fn delete(self) -> Result<(), ()>
[src]
Remove Entry
if it exists.
Errors if it does not exist.
let mut l = WeightedRandomList::new(); l.push(12, 11); l.push(74, 22); l.push(25, 33); { let second = l.entry_first(&22); assert!(second.delete().is_ok(), "element was found and deleted"); } { let second = l.entry_first(&22); assert!(second.delete().is_err(), "element alread gone"); }
Auto Trait Implementations
impl<'container, T> Send for Entry<'container, T> where
T: Send,
T: Send,
impl<'container, T> Sync for Entry<'container, T> where
T: Sync,
T: Sync,
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,