Struct abstutil::collections::Counter
source · [−]Expand description
A counter per key
Fields
map: BTreeMap<T, usize>
sum: usize
Implementations
sourceimpl<T: Ord + PartialEq + Clone> Counter<T>
impl<T: Ord + PartialEq + Clone> Counter<T>
pub fn new() -> Counter<T>
pub fn add(&mut self, val: T, amount: usize) -> usize
pub fn inc(&mut self, val: T) -> usize
sourcepub fn sorted_asc(&self) -> Vec<Vec<T>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn sorted_asc(&self) -> Vec<Vec<T>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Values with the same count are grouped together
pub fn highest_n(&self, n: usize) -> Vec<(T, usize)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn max_key(&self) -> T
pub fn max_key(&self) -> T
If two keys share the maximum, returns one of them arbitrarily (and deterministically)
pub fn max(&self) -> usize
pub fn sum(&self) -> usize
pub fn compare(self, other: Counter<T>) -> Vec<(T, usize, usize)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn borrow(&self) -> &BTreeMap<T, usize>
pub fn consume(self) -> BTreeMap<T, usize>
pub fn is_empty(&self) -> bool
pub fn extend(&mut self, other: Counter<T>)
Trait Implementations
sourceimpl<'de, T: Ord + PartialEq + Clone> Deserialize<'de> for Counter<T> where
T: Deserialize<'de>,
impl<'de, T: Ord + PartialEq + Clone> Deserialize<'de> for Counter<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Ord + PartialEq + Clone> StructuralPartialEq for Counter<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Counter<T> where
T: RefUnwindSafe,
impl<T> Send for Counter<T> where
T: Send,
impl<T> Sync for Counter<T> where
T: Sync,
impl<T> Unpin for Counter<T>
impl<T> UnwindSafe for Counter<T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more