pub struct IndexTreeSet<K> {
pub map: IndexTreeMap<K, ()>,
}Expand description
The ‘Set’ IndexTree data structure
Fields§
§map: IndexTreeMap<K, ()>Implementations§
Source§impl<K: Default> IndexTreeSet<K>
impl<K: Default> IndexTreeSet<K>
Sourcepub fn new() -> IndexTreeSet<K>
pub fn new() -> IndexTreeSet<K>
Makes a new, empty IndexTreeSet.
Does not allocate anything on its own.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut map = IndexTreeSet::new();
map.insert(1);
Source§impl<K: Default> IndexTreeSet<K>
impl<K: Default> IndexTreeSet<K>
Source§impl<K> IndexTreeSet<K>
impl<K> IndexTreeSet<K>
Source§impl<K: Ord> IndexTreeSet<K>
impl<K: Ord> IndexTreeSet<K>
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if the set contains a value for the specified key.
The key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.contains_key(&1), true);
assert_eq!(tree.contains_key(&2), false);Source§impl<K> IndexTreeSet<K>
impl<K> IndexTreeSet<K>
Sourcepub fn contains_index(&self, index: usize) -> bool
pub fn contains_index(&self, index: usize) -> bool
Returns true if the set contains an item in the index position.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.contains_index(0), true);
assert_eq!(tree.contains_index(1), false);Source§impl<K: Ord> IndexTreeSet<K>
impl<K: Ord> IndexTreeSet<K>
Sourcepub fn get(&self, key: &K) -> Option<&K>
pub fn get(&self, key: &K) -> Option<&K>
Returns the index of the corresponding key.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.get(&1), Some(&1));
assert_eq!(tree.get(&2), None);Sourcepub fn get_from_index(&self, index: usize) -> Option<&K>
pub fn get_from_index(&self, index: usize) -> Option<&K>
Returns the index of the corresponding key.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.get_key_from_index(0), Some(&1));
assert_eq!(tree.get_key_from_index(1), None);Source§impl<K: Ord> IndexTreeSet<K>
impl<K: Ord> IndexTreeSet<K>
Sourcepub fn get_index_from_key(&self, key: &K) -> Option<usize>
pub fn get_index_from_key(&self, key: &K) -> Option<usize>
Returns the index of the corresponding key.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.get_index_from_key(&1), Some(0));
assert_eq!(tree.get_index_from_key(&2), None);Sourcepub fn get_key_from_index(&self, id: usize) -> Option<&K>
pub fn get_key_from_index(&self, id: usize) -> Option<&K>
Returns a reference to the key corresponding to the index.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.get_key_from_index(0), Some(&1));
assert_eq!(tree.get_key_from_index(1), None);Source§impl<K> IndexTreeSet<K>
impl<K> IndexTreeSet<K>
Sourcepub fn iter(&self) -> IndexTreeSetIterator<'_, K> ⓘ
pub fn iter(&self) -> IndexTreeSetIterator<'_, K> ⓘ
Gets an iterator over the entries of the set, sorted by key.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut map = IndexTreeSet::new();
map.insert(10);
map.insert(1);
let first_key = map.iter().next().unwrap();
assert_eq!(first_key, &1);Source§impl<K: Default + Ord + Clone> IndexTreeSet<K>
impl<K: Default + Ord + Clone> IndexTreeSet<K>
Sourcepub fn remove(&mut self, key: &K) -> Option<K>
pub fn remove(&mut self, key: &K) -> Option<K>
Removes an item from the map from its corresponding key, returning the key-value pair that was previously in the map.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.remove(&1), Some(1));
assert_eq!(tree.remove(&2), None);Source§impl<K: Default + Ord + Clone> IndexTreeSet<K>
impl<K: Default + Ord + Clone> IndexTreeSet<K>
Sourcepub fn remove_from_index(&mut self, index: usize) -> Option<K>
pub fn remove_from_index(&mut self, index: usize) -> Option<K>
Removes an item from the map from its corresponding index, returning the key-value pair that was previously in the map.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut tree = IndexTreeSet::new();
tree.insert(1);
assert_eq!(tree.remove_from_index(0), Some(1));
assert_eq!(tree.remove_from_index(1), None);Source§impl<K: Default + Ord + Clone> IndexTreeSet<K>
impl<K: Default + Ord + Clone> IndexTreeSet<K>
Sourcepub fn split_off(&mut self, key: &K) -> IndexTreeSet<K>
pub fn split_off(&mut self, key: &K) -> IndexTreeSet<K>
Splits the map into two at the given key. Returns everything after the given key, including the key.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut a = IndexTreeSet::new();
a.insert(1);
a.insert(2);
a.insert(13);
a.insert(17);
a.insert(41);
let b = a.split_off(&13);
assert_eq!(a.len(), 2);
assert_eq!(b.len(), 3);Sourcepub fn split_off_from_index(&mut self, index: usize) -> IndexTreeSet<K>
pub fn split_off_from_index(&mut self, index: usize) -> IndexTreeSet<K>
Splits the map into two at the given index. Returns everything after the given key, including the key.
§Example
Basic usage:
use indextreemap::IndexTreeSet;
let mut a = IndexTreeSet::new();
a.insert(1);
a.insert(2);
a.insert(3);
a.insert(17);
a.insert(41);
let b = a.split_off_from_index(2);
assert_eq!(a.len(), 2);
assert_eq!(b.len(), 3);Trait Implementations§
Source§impl<K: Clone> Clone for IndexTreeSet<K>
impl<K: Clone> Clone for IndexTreeSet<K>
Source§fn clone(&self) -> IndexTreeSet<K>
fn clone(&self) -> IndexTreeSet<K>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more