Struct StringSet

Source
pub struct StringSet { /* private fields */ }
Expand description

A simple set of strings, implemented using a splay tree.

This is specialised version of Set that stores keys as a string.

Implementations§

Source§

impl StringSet

Source

pub fn new() -> StringSet

Constructor

Source

pub fn with_capacity(capacity: usize) -> StringSet

Constructor

Source

pub fn count(&self) -> usize

Get the number of string/value pairs in the StringSet

Source

pub fn is_empty(&self) -> bool

Check if there are any string/value pairs in the StringSet

Source

pub fn clear(&mut self)

Remove all string/value pairs from the StringSet

Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for at least additional more string/value pairs

Source

pub fn get(&self, key: &str) -> Option<&str>

Get a value by string.

If the string is not in the tree then None is returned.

Source

pub fn set(&mut self, key: &str)

Set a value by string.

set attempts to reconfigure the tree for future lookups by promoting the string to the top of the tree.

Source

pub fn unset(&mut self, key: &str)

Unset a value by string.

If the string does not exist, then this function has no effect.

Source

pub fn first(&self) -> Option<&str>

Get the first string in the set

Source

pub fn last(&self) -> Option<&str>

Get the last string in the set

Source

pub fn pop_first(&self) -> Option<&str>

Pop the first string from the set

Source

pub fn pop_last(&self) -> Option<&str>

Pop the last key from the set

Source

pub fn iter(&self) -> StringSetIterator<'_>

Iterate over the string/value pairs in the StringSet

Trait Implementations§

Source§

impl Default for StringSet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> FromIterator<&'a str> for StringSet

Source§

fn from_iter<I: IntoIterator<Item = &'a str>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a StringSet

Source§

type Item = &'a str

The type of the elements being iterated over.
Source§

type IntoIter = StringSetIterator<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.